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

Characters found after end of SQL statement

Status
Not open for further replies.

danieljoo

MIS
Oct 9, 2002
43
US
Can some tell from the following chunk of code why I might be getting this error:


If Request.Querystring("CustomerNumber")= "" then
strsql = "select * from [Attendee]"
If dbwhere <> &quot;&quot; Then
strsql = strsql & &quot; WHERE &quot; & dbwhere
End If
If OrderBy <> &quot;&quot; then
strsql = strsql & &quot; ORDER BY [&quot; & OrderBy & &quot;] &quot; & Session(&quot;Attendee_OT&quot;)
End if
else
myVar2=Request.Querystring(&quot;CustomerNumber&quot;)
strsql = &quot;select * from [Attendee] where Attendee.CustomerNumber =&quot; & &quot;'&quot; & myVar2 & &quot;'&quot; & &quot;;&quot;
If dbwhere <> &quot;&quot; Then
strsql = strsql & &quot; WHERE &quot; & dbwhere
End If
If OrderBy <> &quot;&quot; then
strsql = strsql & &quot; ORDER BY [&quot; & OrderBy & &quot;] &quot; & Session(&quot;Attendee_OT&quot;)
End if
End If
 
this line from your else

strsql = &quot;select * from [Attendee] where Attendee.CustomerNumber =&quot; & &quot;'&quot; & myVar2 & &quot;'&quot; & &quot;;&quot;

The semi colon is the end of line. At least one of your following if statments are appending to the sql string. thus creating an bad query.
 
In your else you have two where's and you have a semicolon in the middle of the line. You are then attempting to concanate more sql to the statement which will fail.

Try taking out the extra where.

HTH,

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top