Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Where Clause as Variable


Message #1 by "Dave Landolin" <dave.landolin@o...> on Mon, 23 Sep 2002 16:53:47
WhereClause = "cust_id = '10022'"

sql = "select cust_id "
sql = sql + "from tbl_customers "
sql = sql + "where '" & WhereClause & "'"

When the asp is sent to the server the server sees the variable enclosed 
in single quotes thereby causing a syntax error:
select cust_id from tbl_customers where 'cust_id = '10022''

How can I get around this??

Thanks in advance,
DL
Message #2 by "Aaron Fleming" <aaronf@w...> on Mon, 23 Sep 2002 11:47:24 -0400
Since cust_id is an INT - remove the single quotes and it should fire
fine.

sql = "select cust_id "
sql = sql + "from tbl_customers "
sql = sql + "where " & WhereClause & ""

A

> -----Original Message-----
> From: Dave Landolin [mailto:dave.landolin@o...] 
> Sent: Monday, September 23, 2002 12:54 PM
> To: ASP Web HowTo
> Subject: [asp_web_howto] Where Clause as Variable
> 
> 
> WhereClause = "cust_id = '10022'"
> 
> sql = "select cust_id "
> sql = sql + "from tbl_customers "
> sql = sql + "where '" & WhereClause & "'"
> 
> When the asp is sent to the server the server sees the 
> variable enclosed 
> in single quotes thereby causing a syntax error:
> select cust_id from tbl_customers where 'cust_id = '10022''
> 
> How can I get around this??
> 
> Thanks in advance,
> DL
> 
> ---
> 
> Improve your web design skills with these new books from Glasshaus.
> 
> Usable Web Menus 
> http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/th
eprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

Message #3 by kyle.b.willman@u... on Mon, 23 Sep 2002 10:52:25 -0500
Try removing the single quotes in the example:

sql = sql + "where '" & WhereClause & "'"

Change to:

sql = sql + "where " & WhereClause

Should work...

Kyle B. Willman
PricewaterhouseCoopers LLP
Office:  xxx.xxx.xxxx
Cell:   xxx.xxx.xxxx


                                                                                                                                    
                      "Dave Landolin"                                                                                               
                      <dave.landolin@o...       To: "ASP Web HowTo" <asp_web_howto@p...>                            
                      us.com>                  cc:                                                                               
                      09/23/2002 11:53         Subject:  [asp_web_howto] Where Clause as Variable                                   
                      AM                                                                                                            
                                                                                                                                    
                      Please respond to                                                                                             
                      "ASP Web HowTo"                                                                                               
                                                                                                                                    
                                                                                                                                    




WhereClause = "cust_id = '10022'"

sql = "select cust_id "
sql = sql + "from tbl_customers "
sql = sql + "where '" & WhereClause & "'"

When the asp is sent to the server the server sees the variable enclosed
in single quotes thereby causing a syntax error:
select cust_id from tbl_customers where 'cust_id = '10022''

How can I get around this??

Thanks in advance,
DL

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20




_________________________________________________________________
         The information transmitted is intended only for the person or
         entity to which it is addressed and may contain confidential
         and/or privileged material.  Any review, retransmission,
         dissemination or other use of, or taking of any action in reliance
         upon, this information by persons or entities other than the
         intended recipient is prohibited.   If you received this in error,
         please contact the sender and delete the material from any
         computer.

Message #4 by Vijay G <happygv@y...> on Mon, 23 Sep 2002 21:13:22 -0700 (PDT)
Dave,

Why should it be passed with single quotes from your ASP page as in your case. Remove the single quotes and send it.

sql = sql + "where " & WhereClause 

This should work.

Cheers!!!
Vijay G


 Dave Landolin wrote:WhereClause = "cust_id = '10022'"

sql = "select cust_id "
sql = sql + "from tbl_customers "
sql = sql + "where '" & WhereClause & "'"

When the asp is sent to the server the server sees the variable enclosed 
in single quotes thereby causing a syntax error:
select cust_id from tbl_customers where 'cust_id = '10022''

How can I get around this??

Thanks in advance,
DL

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20


---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
Message #5 by "Dave Landolin" <dave.landolin@o...> on Tue, 24 Sep 2002 13:22:50
Thanks to all for your help - Greatly appreciated.

  Return to Index