How to update the data in dataset
Ravi Kumar
Select an image from your device to upload
The DataAdapter object uses commands to update the data source after changes have been made to the DataSet. Using the Fill method of the DataAdapter calls the SELECT command; using the Update method calls the INSERT, UPDATE or DELETE command for each changed row. You can explicitly set these commands in order to control the statements used at runtime to resolve changes, including the use of stored procedures. For ad-hoc scenarios, a CommandBuilder object can generate these at run-time based upon a select statement. However, this run-time generation requires an extra round-trip to the server in order to gather required metadata, so explicitly providing the INSERT, UPDATE, and DELETE commands at design time will result in better run-time performance.
SqlConnection con=new SqlConnection("server=localhost;Trusted_Connection=yes;database=northwind");SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter("select * from customers", myConnection);SqlDataAdapter sda = new SqlDataAdapter("select * from customers", con);
sda.InsertCommand.CommandText = "sp_InsertCustomer";sda.InsertCommand.CommandType = CommandType.StoredProcedure;sda.DeleteCommand.CommandText = "sp_DeleteCustomer";sda.DeleteCommand.CommandType = CommandType.StoredProcedure;sda.UpdateCommand.CommandText = "sp_UpdateCustomers";sda.UpdateCommand.CommandType = CommandType.StoredProcedure;