Also, when updating multiple rows, the business objects would have to be matched up against the dataset, which could be problematic.
My next solution was to use an update query as the insertcommand of the dataset, and call the update statement. you could not do a real insert and an update in the same operation. Set Modified() functions you can make the data adapter correctly call the update statement. Accept Changes() marks the row as unchanged, then Set Modified() sets it as updated, even though it started as added.
The Update() method actually scans the locally-cached Data Table to pick out those rows that have been modified. Delete() ' let's edit the contents of a record dr = dt.
Later, the collection of business objects needed to be commited back to the database, however the original dataset is no longer around.
Therefore, when I create rows in my dataset to update back to the database, the data adapter actually attempted to insert new rows, when the rows in question already exist.
Row State value can be : More you can get about these State from MSDN. Step 1: We have a Data Base Helper Class which have a function which return a Sql Data Adapter object of our datacollection Here I am writing SQL Query inside this function.
you can even use Stored Procedure or any thing you want but store result into Sql Data Adapter.
To change an existing row's data, you can directly assign a row's value. Delete() In this example, I'll show you how to add edit, and remove, data from the Northwind database.