Re: simple UPDATE not working



Thanks, that took care of the problem
Peter

Bob Barrows [MVP] wrote:
Getting syntax errors from statements that run when executed in the
database's native query execution tool almost always point to the use of
reserved keywords for table or field names. So it comes as no surprise
that it's the problem here. "last" is a reserved keyword (it's the name
of a proprietary aggregate function in Jet: select last(fieldname) from
table). Your best course of action is to rename the field (the list of
reserved keywords can be found here:
http://www.aspfaq.com/show.asp?id=2080). However, if the fieldname is
untouchable for some reason, you are going to have to remember to
delimit it with brackets [] when using it in a query executed via
ADO/ODBC/etc.



Peter Carlson wrote:
I have a very simple update statement that is not working.

calling raw_execute returns:
DB_E_ERRORSINCOMMAND: Syntax error in UPDATE statement

The sql is:
UPDATE peter set last="Peter" where id=3

However this works just fine
UPDATE peter set num=10 where id=3
delete from peter where id=3

And I can of course copy / paste the statement into access and it
works just fine. Below is all the code I use to connect.

Peter

Table Peter:
id: autonumber
last:text 50
num:int

CString strConnection (_T("Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=temp.mdb;"));
if (!db.Open(strConnection, "", "")) {
MessageBox("Unable to open database");
PostMessage(WM_CLOSE);
return 0;
}

CString sSql;
sSql = "UPDATE peter set last=\"Peter\" where id=3";
db.Execute(sSql);
sSql = "UPDATE peter set num=10 where id=3";
db.Execute(sSql);
sSql = "delete from peter where id=3";
db.Execute(sSql);

.