943,971 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 3607
  • VB.NET RSS
May 15th, 2007
0

problem with update in dataset

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
lukis is offline Offline
14 posts
since Oct 2006
May 15th, 2007
0

Re: problem with update in dataset

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.
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
May 16th, 2007
0

Re: problem with update in dataset

Quote ...
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

VB.NET Syntax (Toggle Plain Text)
  1. Me.oledb_cust_edit.Update(Me.DataSet11)
  2. custrow.AcceptChanges()
Last edited by manal; May 16th, 2007 at 12:29 am.
Reputation Points: 37
Solved Threads: 17
Junior Poster
manal is offline Offline
122 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: creating array for saving location of label
Next Thread in VB.NET Forum Timeline: link two menus





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC