13.3 Editing a Row

Editing a row in a strongly typed DataSet is nearly the same as editing a row in an untyped DataSet . The only real difference is that columns for the rows are accessed using properties of the strongly typed DataSet . The following example illustrates editing data using a strongly typed DataSet :

 // strongly typed DataSet called Northwind containing the Orders table Northwind.OrdersDataTable ordersTable = new Northwind.OrdersDataTable(); // ... code to add new rows to, or Fill the Orders table // modify the employee ID for the first Order Northwind.OrdersRow ordersRow = ordersTable[0]; ordersRow.EmployeeID = 2; 

This example shows editing the same data using an untyped DataSet :

 // untyped DataSet containing the Orders table DataSet ds = new DataSet("Northwind"); DataTable ordersTable = ds.Tables.Add("Orders"); // ... code to define or retrieve the schema for the Orders table // ... code to add new rows to, or Fill the Orders table // modify the employee ID for the first Order DataRow ordersRow = ordersTable.Rows[0]; ordersRow["EmployeeID"] = 2; 


ADO. NET in a Nutshell
ADO.NET in a Nutshell
ISBN: 0596003617
EAN: 2147483647
Year: 2005
Pages: 415

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net