Updating an Access database using a DataAdapter & Dataset

rahulg

New member
Joined
Feb 26, 2009
Messages
2
Programming Experience
1-3
Hello,

I just started coding in .NET and was testing out a few things like reading from an access database and writing to it. Reading is fine, but writing back to it has me frustrated. I've been trying for the past couple of days, looking up on google as well but nothing seems to work.

I have attached the solution and database to this post. If you would be willing to help, please extract the contents to C:\.

Here's a quick explanation of what I'm trying to do:
The table "Table1" has just 1 row. I'm trying to change the contents of the "value" column to "Shift 1 --> Shift 2" or anything else.
It always gives me the error message "Syntax error in UPDATE statement." I am using OleDbCommandBuilder so that I don't have to write my own update statement. I have tried that too and that also failed. Previously it complained about the primary key so I added that too! I'm just stuck here.

Honestly, god knows why MS loves to makes things so hard at times. It seems like things were much easier with DAO in VB 6.0/VBA atleast as far as accessing an Access database was concerned.

Thanks!!
 

Attachments

  • Access Test.zip
    25.5 KB · Views: 28
Last edited by a moderator:
Just an update:

Inside the UpdateCommand, I changed the fields value to [value] and setting to [setting] and that seems to work now, however it still doesn't work with the usual Dataset update method. I also changed the column names to value_ and setting_ to ensure they are not keywords. Then it gave me this error:

Syntax error in query expression '((_ID = ?) AND ((? = 1 AND setting_ IS NULL) OR (setting_ = ?)) AND ((? = 1 AND value_ IS NULL) OR (value_ = ?)))'

God knows why it's generating such an Update statement.
 
Back
Top