1.

How Can We Save All Data From Dataset ?

Answer»

Answer : // create the data adapter SqlDataAdapter dataAdapter = NEW
SqlDataAdapter ("SELECT userId,username FROM USERS ORDER BY username",
sqlConn);
// create an SQLCOMMANDBUILDER - this will automatically generate the
commands, and set the appropriate properties in the dataAdapter
SqlCommandBuilder COMMANDBUILDER = new
SqlCommandBuilder(dataAdapter);
// create the DataSet
DataSet dataSet = new DataSet();
// fill the DataSet using our DataAdapter into a table called users
dataAdapter.Fill (dataSet,"users");
// set the DataGrid source to the one table in our dataset
myDataGrid.DataSource = dataSet.Tables[0];

Then, when we've finished making our changes to the DataSet via the DataGrid, we call

dataAdapter.Update(dataSet);

and the database will now contain the changes we have made.

Then, when we've finished making our changes to the DataSet via the DataGrid, we call

and the database will now contain the changes we have made.



Discussion

No Comment Found