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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update syntax error when updating access db

Status
Not open for further replies.

hobanero

Programmer
Aug 17, 2002
3
US
I am trying to update a record in an access database table that has the name "dietentries".
The fields I am updating are Time, Food, Quantity.
My where clause is based on an ID that is a long integer.
I have tried casting the ID to both Cint and Clng.

My update string is:
"update dietentries set Time = '5AM', Food = 'Bagel', Quantity = '1' where ID = "

My execute statement is:
conn.Execute(updatestring & ID)

Result looks like:
update dietentries set Time = '5AM', Food = 'Bagel', Quantity = '1' where ID = 1

Any Ideas?
Hobanero
 
Figured it out. I had two problems in my database.
1.) There are additional fields in my database that I was not updating and these fields had zero length values. This causes an update syntax error. Because I am new to Microsoft development and Access DBs, I was unaware of this.
2.) One of my database columns was named "Time". Should have caught this because Time is a reserved name by SQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top