Hi there,

i'm working on a project in which i'm creating, editing and deleting customer records from a MS access db. I'm using vb.net 2003.

As with creating and deleting records i dont have any probelms. the problems arise when i come to update the data base if i edit any details. when i debugged it it showed the changes but not in the database. below is the code i used :

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
MsgBox("Do you want to save to database?", MsgBoxStyle.YesNo)
If MsgBoxResult.Yes Then
 
Dim custrow As DataSet1.CustomerRow
custrow = DataSet11.Customer.FindByCust_id(lblCustNo.Text)
custrow.BeginEdit()
custrow.Cust_Address = txtAdd.Text
custrow.Cust_email = txtEmail.Text
'custrow.Cust_id = lblCustNo.Text
custrow.Cust_name = txtName.Text
custrow.Cust_Sname = txtSname.Text
custrow.Cust_Tel = txtTel.Text
custrow.EndEdit()
custrow.AcceptChanges()
Me.oledb_cust_edit.Update(Me.DataSet11)
Me.OleDbConnection1.Close()
End If
Me.oledb_cust_edit.Fill(DataSet11)
interfaces.form2.Show()
interfaces.form4.Hide()
End Sub

it's not giving me any errors. any help please very much appreciated

thank you very much

Luke

I am not a database person but I have heard that if you run your program in the IDE then a new database is created each time the program is run. Try compiling and running the bin/release/ exe.

custrow.AcceptChanges()
Me.oledb_cust_edit.Update(Me.DataSet11)

here is the problem
after calling AcceptChanges the RowState property of custrow will be set to Unchanged so Me.oledb_cust_edit.Update(Me.DataSet11) will return NO change to the dataset

to solve this just inverse the two lines

Me.oledb_cust_edit.Update(Me.DataSet11)
custrow.AcceptChanges()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.