I'm sorry i don't know what to do with vb again 'cause i'm using c#.
But this codes below will be not much different with vb.
Code:
/***
Before you can update the dataSet make sure you
call the EndEdit() method from the dataSet or from your
BindingSource.
*/
this.BindingContext[dataSet, "Table1"].EndEdit();
/***
You can just call the Update() method from dataAdapter which
receives one parameter that is the dataSet but you will always
have concurrency exception raised.
*/
DataSet dsToUpdate = dataSet.Table1.GetChanges();
if (dsToUpdate != null) {
dataAdapter.Update(dsToUpdate);
}
/***
This is the most safe way i think to update dataSet.
You update the dataSet by three steps.
We will use Select() method from dataSet which will return DataTable.
The Select() method receives three parameters that are
filterCriteria, sortCriteria, and DataRowViewState respectively.
If you don't want to add any filter or sort just put null.
*/
if (dataSet.HasChanges()) {
dataAdapter.Update(dataSet.Table1.Select(null, null, DataViewRowState.Deleted));
dataAdapter.Update(dataSet.Table1.Select(null, null, DataViewRowState.Added));
dataAdapter.Update(dataSet.Table1.Select(null, null, DataViewRowState.ModifiedCurrent));
}
/***
After the dataset have been updated you must call the
AcceptChanges() method from the dataSet so the ModifiedCurrent
state record will be changed to Original state means that all of
your changes is commited.
*/
dataSet.Table1.AcceptChanges();
/***
References:
+---------------------|---------------+
+ vb | c# +
+---------------------|---------------+
+ Me | this +
+ () for array | [] +
+ if ..... End If | if (.....) { } +
+---------------------|---------------+
**/
Hope will help you out
.
me_code2004.
Bookmarks