DataAdapter Update problem

bobbynad

Member
Joined
Jun 28, 2003
Messages
20
Location
India
dim Dr as datarow
Dim Dt As DataTable = dg1.datasoursse
Dim Hit As DataGrid.HitTestInfo
Hit = DG1.HitTest(e.X, e.Y)
Dr = Dt.Rows(Hit.Row)
Dr.BeginEdit()
Dr("fieldname") = "xyx"
Dim Ds_temp As DataSet = Ds1.GetChanges(DataRowState.Modified) Ds1 is the main Dataset attached to the Datagrid DG1
Adp1.Update(Ds_temp)
Dr.AcceptChanges()



In the above code , I am modifing a field but , the dataset says that neither of the field is changed or modified , hence I get the problem in the next line when updating DATAADAPTER Adp1.

Where am I wrong
 
Your working to hard.
Since the datagrid is bound to the ds1 (I assume it is your datasource...if not, we have other issues), any edit of the datagrid will be persisted to the dataset. The rowstate will be set to modified and all you have to do is run an .update on the adapter. You may have to include a
Code:
 Me.BindingContext(DataSet, "TableName").EndCurrentEdit()
or, in c#,
this.BindingContext[DataSet,"TableName"].EndCurrentEdit()

before your DataAdapter.update call.


Jon
 
Back
Top