Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating multiple tables

Status
Not open for further replies.

sicohne

Technical User
Jun 30, 2003
51
GB
I seem to be having trouble updating multiple tables. The code is :
------------------------------------------------------------
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Program Files\prefix.mdb;")
Dim da As New OleDbDataAdapter("SELECT * FROM Table1", cn)
Dim da2 As New OleDbDataAdapter("SELECT * FROM Table2", cn)
Dim ds As New DataSet
Dim cmdBuilder As New OleDbCommandBuilder(da)
Dim cmdBuilder2 As New OleDbCommandBuilder(da2)
...
...
...
da2.UpdateCommand = cmdBuilder2.GetUpdateCommand
da.InsertCommand = cmdBuilder.GetInsertCommand
da.UpdateCommand = cmdBuilder.GetUpdateCommand
cn.Open()
da.Update(ds, "Table1")
da2.Update(ds, "Table2")
------------------------------------------------------------
Table1 updates fine, but table2 hits me with "Syntax error in UPDATE command".
Where am I going wrong??
 
I am a bit new to using databases with VB so i'm not sure what a schema definition is. If it helps, table2 has 1 field which is an integer.
 
Does Table 2 have a primary key defined?

Sweep
...if it works dont mess with it
 
It currently does. I get the same error whether it does or doesn't.
 
Does the one field have the AutoNumber feature turned on?
 
I have come up with a work around. Creating a second field and telling the program to update that instead seems to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top