Marc333
asked on
Dataset not updating
I'm having a real problem updating a dataset. Here is the code below:
Dim strsqlST = "SELECT * FROM SoldTemp;"
Dim SoldstempDS1 As New DataSet()
Dim OleDBDataAdapter5 As New OleDb.OleDbDataAdapter(str sqlST, objConnection)
OleDBDataAdapter5.Fill(Sol dstempDS1, "SoldTemp")
Dim strsqlSQ = _
"SELECT * FROM(Solds) WHERE ((City) = 'Westland');"
Dim OleDBDataAdapter4 As New OleDb.OleDbDataAdapter(str sqlSQ, objConnection)
Dim SoldsDS1 As New DataSet()
OleDBDataAdapter4.Fill(Sol dsDS1, "Solds")
Dim dr As DataRow
Dim cb As New OleDbCommandBuilder()
cb = New OleDbCommandBuilder(OleDBD ataAdapter 5)
For Each dr In SoldsDS1.Tables(0).Rows
SoldstempDS1.Tables("SoldT emp").Impo rtRow(dr)
Next
OleDBDataAdapter5.Update(S oldstempDS 1, "SoldTemp")
SoldstempDS1.AcceptChanges ()
As you can see, I've got a commandbuilder in there, but I'm not sure if its the syntax or something else. For your reference, if I put MSGBOX(SoldsTempDS1.Tables (0).rows.C ount), it gives me the correct number of added rows, but the updates never get posted.
Any help would be greatly appreciated.
Marc
Dim strsqlST = "SELECT * FROM SoldTemp;"
Dim SoldstempDS1 As New DataSet()
Dim OleDBDataAdapter5 As New OleDb.OleDbDataAdapter(str
OleDBDataAdapter5.Fill(Sol
Dim strsqlSQ = _
"SELECT * FROM(Solds) WHERE ((City) = 'Westland');"
Dim OleDBDataAdapter4 As New OleDb.OleDbDataAdapter(str
Dim SoldsDS1 As New DataSet()
OleDBDataAdapter4.Fill(Sol
Dim dr As DataRow
Dim cb As New OleDbCommandBuilder()
cb = New OleDbCommandBuilder(OleDBD
For Each dr In SoldsDS1.Tables(0).Rows
SoldstempDS1.Tables("SoldT
Next
OleDBDataAdapter5.Update(S
SoldstempDS1.AcceptChanges
As you can see, I've got a commandbuilder in there, but I'm not sure if its the syntax or something else. For your reference, if I put MSGBOX(SoldsTempDS1.Tables
Any help would be greatly appreciated.
Marc
ASKER
The primary key is an autonumber in the mdb file.
Hi Marc333;
Try moving this line in your code
cb = New OleDbCommandBuilder(OleDBD ataAdapter 5)
To just after thins line of code
Dim OleDBDataAdapter5 As New OleDb.OleDbDataAdapter(str sqlST, objConnection)
But before this line of code.
OleDBDataAdapter5.Fill(Sol dstempDS1, "SoldTemp")
Fernando
Try moving this line in your code
cb = New OleDbCommandBuilder(OleDBD
To just after thins line of code
Dim OleDBDataAdapter5 As New OleDb.OleDbDataAdapter(str
But before this line of code.
OleDBDataAdapter5.Fill(Sol
Fernando
ASKER
No change...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
amyhxu,
Sorry for the slow response but I've been out of town for the last week. I hope to test your code in the next few days and if it looks good I'll award points. Thanks for posting.
Sorry for the slow response but I've been out of town for the last week. I hope to test your code in the next few days and if it looks good I'll award points. Thanks for posting.
HTH
~BC