Problems with an update from dataset to an access

batserra

Member
Joined
Oct 6, 2008
Messages
6
Programming Experience
Beginner
Hi,

I am using vb.net 2005, I have a dataset created with the wizard, and some textboxs linked to a database access, also I have created with a wizard a personesdatatableadapter, oledbconnection1, oledbdatadapter1, oledbcommand1

The fact is that in the textbox, I was perfectly show the data of access, and I can move around them, the problem is when i want to update any field. I see correctly, but when i close and open the application again shows me the same data before the update. So the problem is that the dataset can not to update to the access file

I tryed many ways ,like this:

button update:
VB.NET:
Me.OleDbConnection1.Open () 
Me.OleDbDataAdapter1.Update (Me.PersonesDataSet.Tab them ( "People")) 
PersonesDataSet.AcceptChanges ()

But it's wrong, somebody can help me?

Thank you very much for everything and sorry for my english
 

avile22

Member
Joined
Oct 12, 2008
Messages
8
Programming Experience
5-10
Ive had some updating issues in my database code as well and adding a command builder object fixed it 100%.

The funny thing is that I never even used it in code to do the updating.
I just used the Update command like in your code above.

However, you have to let the Data Adapter know how to handle its internal updates.

JUST ADD THIS CODE IN YOUR PROJECT:


Public Class Form1
Private CB As OleDb.OleDbCommandBuilder


Private Sub Form1_Load
CB = New OleDb.OleDbCommandBuilder(m_daDataAdapter)



And thats it! You never have to call CB at all!
 

Tom

Well-known member
Joined
Aug 23, 2005
Messages
746
Programming Experience
5-10
Ensure that you have proper foreign key relationships set up in both your database and the dataset tables.

In your DataSet set AutoIncrementStep to -1 and an AutoIncrementSeed of 0. When you update your dataset to the database it should refresh with the new proper key values in both tables.
 

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,052
Programming Experience
10+
Read the DNU link in my signature

Ps a line of your code is invalid --> ... them ("People")

pps: read the DW2 link in my signature, section Creating a Simple Data App
 
Top Bottom