Closed Thread Icon

Topic awaiting preservation: Passing variable problem (ASP) (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12988" title="Pages that link to Topic awaiting preservation: Passing variable problem (ASP) (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Passing variable problem (ASP) <span class="small">(Page 1 of 1)</span>\

 
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 11-17-2003 05:31

Hi, guys. Can I ask you this please?
I cannot pass variable to SQL statement.
My code is:

code:
sql = "SELECT WineryName, Name, Region, Price, Star, Vintage, Classic, Screw, AirNZ, Cuisine"
sql = sql & " FROM Winery INNER JOIN (Wine_Winery INNER JOIN Wine ON Wine_Winery.WineID = Wine.WineID )"
sql = sql & " ON Winery.WineryID = Wine_Winery.WineryID WHERE Winery.Region = '"&v_region&"'"

If Request("region")= "" then
v_region = "Canterbury"

elseif Not IsEmpty(Request("region")) Then
v_region = Request("region")
end if
'response.write(v_region)



In my code, response.write(v-region) prints value according to dropdown box. Then I wanted that value to SQL statemnt. In SQL, it did like:

code:
WHERE  Winery.Region = '"&v_region&"'"



I was sure this would worked. Cuz I wrote variable into SQL statement like that before.
But somereason, it did not work. Do you have any idea???
Please help.




Hiroki Kozai

Rhino
Bipolar (III) Inmate

From: New Jersey, USA
Insane since: Jul 2003

posted posted 11-17-2003 11:21

Just move the conditional statement used to get v_region above the building of the SQL statement. You are getting the value after you build the statement. This wouldn't work unless you were building prepared statements.



Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 11-17-2003 20:55

Hi, mate.
Thanks for that.
It works fine.
Cheers.

Hiroki Kozai

« BackwardsOnwards »

Show Forum Drop Down Menu