By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Syntax error in query...(ADO.NET + MS Access)

P: n/a
I am trying to update a field in Access db (.mdb) via a DataSet using
the following code. I am continously getting this error:

Has anybody seen this before?

1. If I try using the same code for any other .mdb file, it works
perfectly.

2. This is a Winform application, so no problems about the ASPNET wp
being granted rights.

Message:
"Syntax error in query expression '( (RowNumber = ?) AND ((? = 1 AND
TimeStampValue IS NULL) OR (TimeStampValue = ?)) AND ((? = 1 AND MS IS
NULL) OR (MS = ?)) AND ((? = 1 AND Frame_Number IS NULL) OR
(Frame_Number = ?)) AND ((? = 1 AND Direction IS NULL) OR (Direction =
?)) AND ((? = 1 AND'."

CODE
{
string query = "select * from tablename";

//conn is the respective connection
OleDbDataAdapter da= new OleDbDataAdapter(query, conn);

da.Fill(myDS, "tablename");

OleDbCommandBuilder myOleDbCommandBuilder = new
OleDbCommandBuilder(da);

myDS.Tables["tablename"].Rows[0]["somerow"] = "somevalue";

//following line throws the exception
da.Update(myDS, "tablename");

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I've never done an update in this way, but the .NET framework
documentation says that you must set the SelectCommand property of the
OleDbDataAdapter. This gives the CommandBuilder a hint on how to
formulate an update statement. See the documentation for the
OleDbCommandBuilder Class.

Bill E.
Hollywood, FL

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.