DbDataAdapter.Update Method
Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the DataSet.
Overload List
Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified array of DataRow objects.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Function Update(DataRow()) As Integer
[C#] public int Update(DataRow[]);
[C++] public: int Update(DataRow*[]);
[JScript] public function Update(DataRow[]) : int;
Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Overrides Public Function Update(DataSet) As Integer Implements IDataAdapter.Update
[C#] public override int Update(DataSet);
[C++] public: int Update(DataSet*);
[JScript] public override function Update(DataSet) : int;
Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataTable.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Function Update(DataTable) As Integer
[C#] public int Update(DataTable);
[C++] public: int Update(DataTable*);
[JScript] public function Update(DataTable) : int;
Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified array of DataRow objects.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Protected Overridable Function Update(DataRow(), DataTableMapping) As Integer
[C#] protected virtual int Update(DataRow[], DataTableMapping);
[C++] protected: virtual int Update(DataRow*[], DataTableMapping*);
[JScript] protected function Update(DataRow[], DataTableMapping) : int;
Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the DataSet with the specified DataTable name.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Function Update(DataSet, String) As Integer
[C#] public int Update(DataSet, string);
[C++] public: int Update(DataSet*, String*);
[JScript] public function Update(DataSet, String) : int;
Example
[Visual Basic, C#, C++] The following example uses the derived class, OleDbDataAdapter, to Update the data source. This example assumes that you have created an OleDbDataAdapter and a DataSet.
[Visual Basic, C#, C++] Note This example shows how to use one of the overloaded versions of Update. For other examples that might be available, see the individual overload topics.
[Visual Basic] Public Function CreateCmdsAndUpdate(myDataSet As DataSet, myConnection As String, mySelectQuery As String, myTableName As String) As DataSet Dim myConn As New OleDbConnection(myConnection) Dim myDataAdapter As New OleDbDataAdapter() myDataAdapter.SelectCommand = New OleDbCommand(mySelectQuery, myConn) Dim custCB As OleDbCommandBuilder = New OleDbCommandBuilder(MyDataAdapter) myConn.Open() Dim custDS As DataSet = New DataSet myDataAdapter.Fill(custDS) ' Code to modify data in DataSet here myDataAdapter.Update(custDS, myTableName) myConn.Close() Return custDS End Function 'SelectOleDbSrvRows [C#] public DataSet CreateCmdsAndUpdate(DataSet myDataSet,string myConnection,string mySelectQuery,string myTableName) { OleDbConnection myConn = new OleDbConnection(myConnection); OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(); myDataAdapter.SelectCommand = new OleDbCommand(mySelectQuery, myConn); OleDbCommandBuilder custCB = new OleDbCommandBuilder(myDataAdapter); myConn.Open(); DataSet custDS = new DataSet(); myDataAdapter.Fill(custDS); //code to modify data in dataset here myDataAdapter.Update(custDS, myTableName); myConn.Close(); return custDS; } [C++] DataSet* CreateCmdsAndUpdate(DataSet* myDataSet,String* myConnection,String* mySelectQuery,String* myTableName) { OleDbConnection* myConn = new OleDbConnection(myConnection); OleDbDataAdapter* myDataAdapter = new OleDbDataAdapter; myDataAdapter->SelectCommand = new OleDbCommand(mySelectQuery, myConn); OleDbCommandBuilder* custCB = new OleDbCommandBuilder(myDataAdapter); myConn->Open(); DataSet* custDS = new DataSet; myDataAdapter->Fill(custDS); //code to modify data in DataTable here myDataAdapter->Update(custDS, myTableName); myConn->Close(); return custDS; }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
See Also
DbDataAdapter Class | DbDataAdapter Members | System.Data.Common Namespace