ASP.NET Tutorials
Tutorials
ASP.NETManaging Data with ADO.NET DataSets and C#
Table of Contents
Managing Data with ADO.NET DataSets and C#
Managing Data with ADO.NET DataSets and C# - Page 2
Note that the Customers element and the Orders elements are shown as sibling elements. If you wanted to have the Orders elements show up as children of their respective parent elements, the Nested property of the DataRelation would need to be set to true and you would add the following:
The following code shows what the resulting output would look like, with the Orders elements nested within their respective parent elements.
Using DataSet with DataAdapters to Modify Data
We can also use DataAdapters to modify data in the database. There are several properties that are available to perform these operations.
Let's see some of the properties:
ad.SelectCommand = new SqlCommand("SELECT * FROM Person",myConnection);
ad.UpdateCommand = new SqlCommand("UPDATE TABLE Person SET Name='john' WHERE PersonID = 1");
ad.DeleteCommand = new SqlCommand("DELETE TABLE Person WHERE PersonID = 1");
ad.InsertCommand = new SqlCommand("INSERT INTO PERSON VALUES('NewName') ");
All the properties are self explanatory. SelectCommand property is used to select, Update command property is used to update and so forth.
When we issue the command we can just later fill the Dataset with the DataAdatper and later we can bind the dataset to datagrid to view the result on the user interface.
