R
Rich
Hello,
I get an error message when I try to update an
oleDBdataAdapter: "Syntax error in Update statement"
Here is what I have:
for this project I am using all data components from the
toolbox (instead of just writing code for them - VB 2002),
an oleDBconnection, oleDBdataAdapter, Dataset. These all
appear to work fine for loading data and displaying on a
form. I am connecting to an Access mdb. 10 rows of data
5 fields from tbl1 in Access.
In the dataset component, ds1, I named the table dtTbl1
("tbl1" in Access). I then bind each textbox on the form
to a field in ds1. The data displays correctly on the
form and I can cycle through all the records. Then I have
an Update button on the form. The code where I get the
error is this in the button click event:
__________________________________________
Cursor.Current = Cursors.Default
Try
OleDbDataAdapter1.Update(ds1, "tbl1")
Catch ex As Exception
MsgBox(ex.Message)
End Try
___________________________________________
If I modify the data in a textbox and click the update
button there are no messages. But if I move to another
record and then click the update button, I get the error
message - syntax error in update statement. And the data
does not update in the Access mdb.
Here is my Update Commandtext (from the property sheet):
UPDATE tbl1 SET fld1 = ?, fld2 = ?, fld3 = ?, fld4 = ?,
fld5 = ?
I am guessing that I need to replace the ? with
something. Do I put the ds1 field names here or the
textbox names? or do I leave this alone?
Thanks,
Rich
I get an error message when I try to update an
oleDBdataAdapter: "Syntax error in Update statement"
Here is what I have:
for this project I am using all data components from the
toolbox (instead of just writing code for them - VB 2002),
an oleDBconnection, oleDBdataAdapter, Dataset. These all
appear to work fine for loading data and displaying on a
form. I am connecting to an Access mdb. 10 rows of data
5 fields from tbl1 in Access.
In the dataset component, ds1, I named the table dtTbl1
("tbl1" in Access). I then bind each textbox on the form
to a field in ds1. The data displays correctly on the
form and I can cycle through all the records. Then I have
an Update button on the form. The code where I get the
error is this in the button click event:
__________________________________________
Cursor.Current = Cursors.Default
Try
OleDbDataAdapter1.Update(ds1, "tbl1")
Catch ex As Exception
MsgBox(ex.Message)
End Try
___________________________________________
If I modify the data in a textbox and click the update
button there are no messages. But if I move to another
record and then click the update button, I get the error
message - syntax error in update statement. And the data
does not update in the Access mdb.
Here is my Update Commandtext (from the property sheet):
UPDATE tbl1 SET fld1 = ?, fld2 = ?, fld3 = ?, fld4 = ?,
fld5 = ?
I am guessing that I need to replace the ? with
something. Do I put the ds1 field names here or the
textbox names? or do I leave this alone?
Thanks,
Rich