p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   Request("var") issue (http://p2p.wrox.com/showthread.php?t=13269)

cmiller May 21st, 2004 03:18 PM

Request("var") issue
 
Hello,

My issue is that I am trying to pass a Query String to an ASP script that then searches for that variable in an SQL database. The script works fine until I subject it to my lack of ASP knowledge. Here's the details:


file call:
Code:

clientlist_alph.asp?alph=a
Script Line:
Code:

var oRs = theDatabase.execute("SELECT * FROM COMPANY WHERE
COMPANY_IMAGEFOLDER LIKE '"& Request("alph") &"%' ORDER BY
COMPANY_IMAGEFOLDER");

I get this error:
Code:

POST /control/clientlist_alph.asp |22|80040e14|[Microsoft]
ODBC_SQL_Server_Driver][SQL_Server]Line_1:_Incorrect_syntax_near_'0'.
500

However it works fine when I run it without that piece:
Code:

var oRs = theDatabase.execute("SELECT * FROM COMPANY ORDER BY
COMPANY_IMAGEFOLDER");

Got any ideas what I'm doing wrong? Any help would be appreciated.

----------
~cmiller

happygv May 21st, 2004 10:20 PM

Have you defined the CONNECTION object and RECORDSET objects? Can you post that code too?

AFAIK, var is not a Keyword used to define a variable in ASP. Are you doing that using Javascript/jscript?

var oRs=.....

Regarding Request("alph")...

Please use
Code:

Response.write Request("alph")
to see if that prints the value as "a" when your querystring values is passed as "a"

I would suggest you to better use Request.QueryString("alph") instead of Request("alph").

If that prints the value as "a", then do a response.write for the sql statement.

Response.Write "SELECT * FROM COMPANY WHERE
COMPANY_IMAGEFOLDER LIKE '"& Request("alph") &"%' ORDER BY
COMPANY_IMAGEFOLDER"
Response.End 'To terminated the page being processed by IIS at this level, use

Copy Paste this in your Query window to see if that returns the expected result.

Let us know if you find any thing wierd.
Hope that helps.
Cheers!

-Vijay G


All times are GMT -4. The time now is 10:42 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.