Displaying single table database hierarchy with DataSet and DataRelations
Hierarchies can be difficult to store SQL tables and even more difficult to query and display. This Example will show you how you can use DataRelation to convert single table hierarchy in to nested XML and then use XSLT to transform it to nested list.
The text of this article is not in this database — only its details are. The old site it was published on is gone, but the Internet Archive kept a copy: Displaying single table database hierarchy with DataSet and DataRelations


eliza sahooPosted Jun 7, 2010, 3:42 AM EDT
During the development of a page you may need to populate a number of controls from DB. In that case you have to write a number of functions to populate different controls. In this tip I am going to show you a way to do all these operations in a single function. Step 1: - Write the different queries for getting the data from the DB for different controls in a single string variable by separating them with semicolon. Ex - //Create the SQL query. string selectQueryForControlPopulation = "SELECT COL1,COL2,... FROM TABLE_NAME1 WHERE CONDITION; SELECT COL1,COL2,..FROM TABLE_NAME2 WHERE CONDITION; ......"; Step 2: - Create the DataAdapter, DataSet object. Execute the query and fill the DataSet object. Ex - //Create the Connection object. OleDbConnection oConnection = newOleDbConnection(ConfigurationSettings.AppSettings["SQLConnectionString"]); //Create the Command object. OleDbCommand oCommand = new OleDbCommand(selectQueryForControlPopulation , oConnection ); //Create the DataAdapter object and set its property. OleDbDataAdapter oAdapter = new OleDbDataAdapter(); oAdapter .SelectCommand = oCommandPopulateOrganizations; // Create a DataSet object. DataSet oDataSet = new DataSet(); //Filling the DataSet object. oAdapter .Fill(oDataSet); (**) The DataSet object contain the result of different queries as different tables. We can access those table to fill our controls. http://www.mindfiresolutions.com/Populate-multiple-controls-from-DB-in-a-single-function-using-a-single-DataSet-831.php
eric fritzPosted Feb 27, 2008, 10:36 PM EST
Hi Jigar, Do you know why I receive the following error: System.ArgumentNullException: 'column' argument cannot be null. on the Datarelation line: Dim relation As New DataRelation("ParentChild", result.Tables("Employee").Columns("EmployeeID"), result.Tables("Employee").Columns("ReportsTo"), True) Thanks