954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem with update in dataset

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 :

PrivateSub 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

lukis
Newbie Poster
14 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

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.

waynespangler
Posting Pro in Training
461 posts since Dec 2002
Reputation Points: 84
Solved Threads: 58
 
custrow.AcceptChanges() Me.oledb_cust_edit.Update(Me.DataSet11)


here is the problem
after calling AcceptChanges the RowState property of custrow will be set toUnchanged 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()
manal
Junior Poster
122 posts since Mar 2006
Reputation Points: 37
Solved Threads: 17
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You