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;
|