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

Syntax Error

Status
Not open for further replies.

mot98

MIS
Jan 25, 2002
647
CA
Hi All,

I am getting a Syntax Error on this code, and I can't see where I am going wrong.

<%
Dim ItemVendor
ItemVendor = Request.Form(&quot;VendorId&quot;)
Dim oRSb
Set oRSb=Server.CreateObject(&quot;ADODB.Recordset&quot;)
sqltext= &quot; SELECT ItemType FROM Items WHERE ItemVendor = &quot; & ItemVendor & &quot;;&quot;
oRSb.Open sqltext , &quot;DSN=Clothier&quot;
oRSb.MoveFirst
%>

It is telling me I have a &quot;missing operator&quot; in my SQL text.

TIA for any help


mot98..[peace]

&quot;Where's the beer?&quot;
 
maybe this will work
sqltext= &quot; SELECT ItemType FROM Items WHERE ItemVendor = &quot; sqltext= sqltext & &quot; ItemVendor &quot; & &quot;;&quot;

My sql is rusty. But its worth a try.

provide tools to let people become their best.
 
No..I am still getting the error???

I have looked at other examples of SQL text, and this line looks good...I am not sure what is happening here??

sqltext = &quot;SELECT ItemType FROM Items WHERE ItemVendor = & VendorId&quot;

It is erroring out at ItemVendor =



mot98..[peace]

&quot;Where's the beer?&quot;
 
I'm alittle confused on what you're trying to get from the ItemVendor fields. From what I know the values after the = operator has to be something and not the field itself. like
SELECT ItemType FROM Items WHERE ItemVendor = 'vendor'

provide tools to let people become their best.
 
Just a wild guess.... is ItemVendor a character field that can possibly contain alphabetic characters? If so, you probably need some quotes, like this:

sqltext= &quot; SELECT ItemType FROM Items WHERE ItemVendor = '&quot; & ItemVendor & &quot;';&quot;

See where I have added the single quotes.
I dunno, just a shot.
 
P.S. I agree with onpnt that it is a little confusing when the variable is the same name as the column in the table. Because, when we refer to 'ItemVendor', I'm not sure if we are talking about the variable of the table's column. I prefer to do this:

<%
Dim ItemVendor
parmVendor = Request.Form(&quot;VendorId&quot;)
Dim oRSb
Set oRSb=Server.CreateObject(&quot;ADODB.Recordset&quot;)
sqltext= &quot; SELECT ItemType FROM Items WHERE ItemVendor = '&quot; & parmVendor & &quot;';&quot;
oRSb.Open sqltext , &quot;DSN=Clothier&quot;
oRSb.MoveFirst
%>


Do you agree? No?
 
You don't need to have the ending &&quot;;&quot; at all since you are not continuing your SQL statement. if you were using the ORDER BY 'somthing' then you would use them to connect that. this should work fine for the error you are getting

sqltext= &quot; SELECT ItemType FROM Items WHERE ItemVendor = &quot; & ItemVendor
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top