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

Syntax Error (missing operator)

Status
Not open for further replies.

Airpan

Technical User
Jun 14, 2005
172
US
I need a new set of eyes on this I think. I ran the following query in Access:
Code:
UPDATE cust_inventory 
SET [STK]='3450',[YR]='2000',[MK]='Chevrolet',[MD]='6500',[TYPE]='Recyle',
[MILES]='600000',[HRS]='4',[GVW]='90000',[FRGVW]='10000',[RGVW]='80000',
[ENGM]='Cummins',[ENGMOD]='50L',[HP]='550',[TR]='Auto',[TRM]='Allison',
[BMK]='Rugby',[CAP]='20ft',[PRICE]='600000',[RTIRE]='50',[FRTIRE]='50',
[RR]='502',[WB]='1004',[IGVW]='20000' WHERE [ListingID]= 113;
It runs successfully.
I get the following error when I run a similar query in my asp page:
Syntax error (missing operator) in query expression '[ListingID]='.Line 46
Line 46 reads:
Code:
Set Rec = oConn.Execute("UPDATE cust_inventory SET [STK]='"& frmstk &"',[YR]="& frmyear &",[MK]='"& frmmake &"',[MD]='"& frmmodel &"',[TYPE]='"& frmtype &"',[MILES]='"& frmmiles &"',[HRS]="& frmhours &",[GVW]="& frmGVW &",[FRGVW]='"& frmFRGVW &"',[RGVW]='"& frmRGVW &"',[ENGM]='"& frmengm &"',[ENGMOD]='"& frmengmod &"',[HP]="& frmhp &",[TR]='"& frmtrans &"',[TRM]='"& frmtransmk &"',[BMK]='"& frmbodymk &"',[CAP]="& frmcap &",[PRICE]='"& frmprice &"',[RTIRE]="& frmrtire &",[FRTIRE]="& frmfrtire &",[RR]='"& frmrr &"',[WB]="& frmwb &",[IGVW]="& frmIGVW &" WHERE [ListingID]= "& frmlisting &" ")
The code that holds the form data:
Code:
<%=Response.Write("Welcome ")%>
<%=Response.Write(Session("UserName"))%>
<body>
<%
UserID = Session("UserName")
frmstk=Request.Form("stk")
frmlisting=Request.Form("listing")
frmyear=Request.Form("year")
frmmake=Request.Form("make")
frmmodel=Request.Form("model")
frmtype=Request.Form("type")
frmmiles=Request.Form("miles")
frmhours=Request.Form("hours")
frmGVW=Request.Form("GVW")
frmFRGVW=Request.Form("FRGVW")
frmRGVW=Request.Form("RGVW")
frmengm=Request.Form("engm")
frmengmod=Request.Form("engmod")
frmhp=Request.Form("hp")
frmtrans=Request.Form("trans")
frmtransmk=Request.Form("transmk")
frmbodymk=Request.Form("bodymk")
frmcap=Request.Form("cap")
frmprice=Request.Form("price")
frmrtire=Request.Form("rtire")
frmfrtire=Request.Form("frtire")
frmrr=Request.Form("rr")
frmwb=Request.Form("wb")
frmIGVW=Request.Form("igvw")
'frmopt=Request.Form("opt")
if request.form("submit") <> "" Then

~E
 
That error message is almost always caused by misspelling a column name. I suggest you double check that first.

-George

"the screen with the little boxes in the window." - Moron
 
always do a response.write on your sql statement...to make sure that it is constructed well...copy and paste the output and then run it in access to make sure everything is correct...

-DNG
 
DNG,
I tried putting in the Response.Write(sql) and it didn't write the sql statement. Am I writing it wrong?
Code:
dim oConn, Rec, sConn, sFilePath

  	Set oConn = Server.CreateObject("ADODB.Connection")
   	sFilePath = Server.MapPath("db/logins.mdb")
   	sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sFilePath & ";"
   	oConn.Open sConn
 	Set Rec = oConn.Execute("UPDATE cust_inventory SET [STK]='"& frmstk &"',[YR]="& frmyear &",[MK]='"& frmmake &"',[MD]='"& frmmodel &"',[TYPE]='"& frmtype &"',[MILES]='"& frmmiles &"',[HRS]="& frmhours &",[GVW]="& frmGVW &",[FRGVW]='"& frmFRGVW &"',[RGVW]='"& frmRGVW &"',[ENGM]='"& frmengm &"',[ENGMOD]='"& frmengmod &"',[HP]="& frmhp &",[TR]='"& frmtrans &"',[TRM]='"& frmtransmk &"',[BMK]='"& frmbodymk &"',[CAP]="& frmcap &",[PRICE]='"& frmprice &"',[RTIRE]="& frmrtire &",[FRTIRE]="& frmfrtire &",[RR]='"& frmrr &"',[WB]="& frmwb &",[IGVW]="& frmIGVW &" WHERE [ListingID]= "& frmlisting &" ")
	Response.Write(sql)

~E
 
Try something like this:
Code:
Dim sql
sql = "UPDATE cust_inventory SET [STK]=  etc etc etc "
Response.Write(sql)
Set Rec = oConn.Execute(sql)
 
Thanks guitarzan. Here is what it wrote out:
Code:
UPDATE cust_inventory SET [STK]='1298',[YR]=1960,[MK]='Freightliner',[MD]='AK47',[TYPE]='Refuse',
[MILES]='under60K',[HRS]=5,[GVW]=90000,[FRGVW]='10000',[RGVW]='88016',
[ENGM]='Tecumseh',[ENGMOD]='3L',[HP]=100,[TR]='Automatic',[TRM]=
'Chevrolet',[BMK]='ThermoKing',[CAP]=12,[PRICE]='100,000',[RTIRE]=1001,
[FRTIRE]=1004,[RR]='10R48',[WB]=126,[IGVW]=1200 WHERE [ListingID]=

It looks like I am somehow not catching the form variable for Listing ID?
I have a hidden input type on my form and a variable set to request it from the form... I don't get it. Am running the above sql in access and see if it runs.

~E
 
OK I got it... forgot to include the Request.QueryString information on a page and it wasn't catching the variable. Thanks for the troubleshooting help. Aiy yih yih.:eek:/

~E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top