Updating the Database
To make this easier, we are going to create a method that we will call to update the database. We could probably emulate the old ADO Data Control’s behavior, but instead let’s create an UpdateChanges method:
Public Sub UpdateChanges() Dim dsTemp As DataSet Try If mAdapter.InsertCommand.CommandText = "" And _ mAdapter.UpdateCommand.CommandText = "" And _ mAdapter.DeleteCommand.CommandText = "" Then Exit Sub End If Me.ParentForm.BindingContext(Me).EndCurrentEdit() If mDataSet.HasChanges Then mAdapter.Update(mDataSet.Tables(mintBoundTable).GetChanges) mDataSet.AcceptChanges() mDataSet.Clear() mAdapter.Fill(mDataSet, mintBoundTable) End If Catch errobj As Exception Throw errobj End Try End Sub
First the procedure tests if ...
Get ADO.NET Programming in Visual Basic™ .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.