PDA

Click to See Complete Forum and Search --> : Syntax error in UPDATE statement.


pnj
Nov 19th, 2000, 11:42 AM
this should be simple but.......
I have an ASP page that has a form w/ four text fields and on hidden field. it calls a page called update that has this code in it.
++++++++++++++++++++++
dim FN,LN,EM,PN,SH
FN = request.form("theDate") 'date of the event
LN = request.form("location")'location of the event
EM = request.form("hours") 'time of the event
PN = request.form("title") 'main heading for event(title)
SH = request.form("description")'text describing the event w/ some detail
PW = request.form("ID")

SQL = "Update main_event set date='" & FN & "', location='" & LN & "'"
SQL = SQL & ", heading='" & EM & "', event='" & PN & "'" & _
", hours='" & SH & "', Password='" & PW & "' where ID =" & request.form("id")
response.write SQl 'for testing
set conn = server.createobject("ADODB.Connection")
conn.open "pnj" 'DSN is pnj
conn.execute SQl
conn.close
set conn = nothing

++++++++++++++++++++
the error I get is:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.

it says there is an error on line 16 (conn.execute sql)

does anyone see anything wrong w/ this?
the really strange thing is this code I took from another project and that project would work fine. I know I am just overlooking something simple.....

thanks

monte96
Nov 20th, 2000, 09:12 AM
I think you need a userid and PW for the connection. That info is not stored in the DSN.

pnj
Nov 20th, 2000, 09:38 AM
I'm not sure I know what you meen.

correct me if I am wrong(i usually am)
the DSN points to the database. the database named pnj has a table called main_event that holds the fields named:
date, location, heading, event, hours, Password and ID.

the user already logged in using a password and username.

I really don't get this stuff. One page works fine, I copied the sql string and changed the names to fit my database and now it won't work. but the syntax is the same as the original one that did work????

thanks again

monte96
Nov 21st, 2000, 10:47 PM
The user logging in to your application has NOTHING to do with the userid and password for the database connection.

pnj
Nov 22nd, 2000, 12:19 AM
I figured it out....
my field names are 'saved' words.
date and hours I changed and now it works.
what do you meen by user id and password?

the data base is a simple access DB.

anyway it works no so no biggie.

thanks

monte96
Nov 22nd, 2000, 09:40 AM
I guess I just assumed that you would not be accessing an Access database using ODBC..

You would need a userid & password to log into a DBMS such as SQL Server or Oracle.

pnj
Nov 22nd, 2000, 10:22 AM
Just a simple simple web site.

what should one use instead of ODBC when using Access?

or should I just stick w/ ODBC becouse it works?

thanks and sorry for the confusion.

monte96
Nov 27th, 2000, 10:57 AM
Use the Jet 4.0 provider and ADO instead of ODBC. The OLEDB Jet provider is faster.