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 Chris Miller 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.

Marmalade

Technical User
Jan 30, 2002
29
US
Hey, folks,

I'm trying to run a SQL query against an Access database via an ASP page that uses information entered into a form, and keep getting the following error message:

"Characters found after end of SQL statement"

The code generating the error looks like this:

Code:
If  Request.Form(&quot;course&quot;) <> &quot;&quot; Then
SQL = &quot;Select * FROM Items &quot;
SQL = SQL & &quot;WHERE Course_Number LIKE '&quot; & Request.Form(&quot;course&quot;) & &quot;'&quot;
End If
Set objRS = objConn.Execute(SQL)

I've tried playing with the end quotes on the SQL statement a million ways, but can't get it to stop generating this error. Can anyone tell me what I'm doing wrong?

Thanks,

M
 
Try this instead.

course = Request.Form(&quot;course&quot;)

If Request.Form(&quot;course&quot;) <> &quot;&quot; Then
SQL = &quot;Select * FROM Items &quot;
SQL = SQL & &quot;WHERE Course_Number LIKE '&quot; & course & &quot;'&quot;
End If
Set objRS = objConn.Execute(SQL)

the extra set of quotes may be throwing it off in the SQL string
 
Note also that Access typically prefers double quotes around strings. codestorm
Fire bad. Tree pretty. - Buffy
Hey, I'm operating on a limited mental budget here.
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top