Update Table

bfafiani

Member
Joined
Mar 30, 2006
Messages
8
Programming Experience
1-3
I have a dataform which I created myself, it just has a few textbox fields and a checkbox which are all bound to the relevent db column.
I am calling this form when I want to create a new record or when I want to edit an existing record. Adding is working fine but editing is not. The table does not seem to be updated when I press the update/ok button.
The interesting thing is, for debuggin purposes I place a datagrid on the form which is bound to the same dataset. If I make a change there and press the ok button (i.e. run the same update code) the changes are written to the table.
I enclose the update code, but I feel the problem is not here.
PrivateSub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
Try
Me.OleDbConnection2.Open()
OleDbDataAdapter1.Update(DsAddEdit1)
MsgBox("updated!")
Catch ex As Exception
MsgBox(ex.ToString)
Finally
Me.OleDbConnection2.Close()
EndTry
Me.Hide()
EndSub


Has anyone come across such a problem or have a possible solution? Any help would be greatfully appreciated.
 
Fix

Just to let everyone know that I have resolved this problem by moving to the next record before updating the table. Don't understand why this works but it does, found it by chance.
i.e. the first line of code below

Me.BindingContext(DsAddEdit1, "tStudents").Position = (Me.BindingContext(DsAddEdit1, "tStudents").Position + 1)
Try
Me.OleDbConnection2.Open()
OleDbDataAdapter1.Update(DsAddEdit1)
Catch ex As Exception
MsgBox(ex.ToString)
Finally
Me.OleDbConnection2.Close()
End Try
Me.Hide()
 
Back
Top