Updating the Data
Use the adapter's Update method to update the data. This overloaded method can take a DataTable as a parameter and will commit all the changes made to the data source. The name of the data table can be passed as an argument as well to update the entire dataset in a more traditional manner. When using a data table as an argument to the Update method, the adapter evaluates the changes that have been made to the data table and executes the appropriate command for each row (INSERT, UPDATE, or DELETE).
The example below updates the Title of one of the Calendar entries.
using (GoogleConnection connection = new GoogleConnection(connectionString)) {
GoogleDataAdapter dataAdapter = new GoogleDataAdapter(
"SELECT Id, Title FROM Calendar", connection);
dataAdapter.UpdateCommand = new GoogleCommand(
"UPDATE Calendar SET Title = @Title " +
"WHERE Id = @ID", connection);
dataAdapter.UpdateCommand.Parameters.AddWithValue("@Title", "Title");
dataAdapter.UpdateCommand.Parameters.AddWithValue("@Id", "Id");
DataTable table = new DataTable();
dataAdapter.Fill(table);
DataRow firstrow = table.Rows[0];
firstrow["Title"] = "Main Event";
dataAdapter.Update(table);
Console.WriteLine("Rows after update.");
foreach (DataRow row in table.Rows) {
Console.WriteLine("{0}: {1}", row["Id"], row["Title"]);
}
}