Updating a boolean value in an Access DB

B

Brad Markisohn

I'm having problems updating a boolean value in an Access database. The
value is defined as a Yes/No type that I've always assumed could be treated
as a simple boolean. To update the value, I retrieve the data from the
specified table into a DataTable from a OleDbDataAdapter. I cycle through
the rows looking for the specific value to replace. I then replace the
value in the DataTable then create an UPDATE query and run the
OleDbDataAdapter's UpdateCommand method. Here's the exception message that
I get: "System.Data.OleDB.OleDbException: Syntax error in UPDATE statement."
I've been able to replace non-boolean values without any problems, but I
keep hitting a snag on the booleans. Here's an example of the query that
I'm using in the UpdateCommand:

"UPDATE Device SET Mg = 'True' WHERE NAME = 'Desired Name'"

I've also tried replacing 'True' with its numeric equivalent (-1) with the
same results

Any assistance would be greatly appreciated.

Brad
 
P

Paul Clement

¤ I'm having problems updating a boolean value in an Access database. The
¤ value is defined as a Yes/No type that I've always assumed could be treated
¤ as a simple boolean. To update the value, I retrieve the data from the
¤ specified table into a DataTable from a OleDbDataAdapter. I cycle through
¤ the rows looking for the specific value to replace. I then replace the
¤ value in the DataTable then create an UPDATE query and run the
¤ OleDbDataAdapter's UpdateCommand method. Here's the exception message that
¤ I get: "System.Data.OleDB.OleDbException: Syntax error in UPDATE statement."
¤ I've been able to replace non-boolean values without any problems, but I
¤ keep hitting a snag on the booleans. Here's an example of the query that
¤ I'm using in the UpdateCommand:
¤
¤ "UPDATE Device SET Mg = 'True' WHERE NAME = 'Desired Name'"
¤
¤ I've also tried replacing 'True' with its numeric equivalent (-1) with the
¤ same results
¤
¤ Any assistance would be greatly appreciated.

Use the numeric constant True, not the string value.

"UPDATE Device SET Mg = True WHERE NAME = 'Desired Name'"


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top