|
 |
asp_databases thread: recordset query cars
Message #1 by "Anthony Ekperechi" <tonycom1@h...> on Wed, 21 Feb 2001 12:05:17 -0000
|
|
Hi,
This is my code which is not working:
Set rsRpt = Server.CreateObject("ADODB.Recordset")
'strsql = "SELECT * FROM Orders where customerID ='" & frmUser & "'"
strsql = "SELECT * from cars where make = '" & frmUser & "'"
Request("model") &_
"ORDER by model"
<TD><SELECT id=DropUser name=DropUser style="HEIGHT: 22px; WIDTH:
88px"><OPTION selected value="BMW">BMW</OPTION><OPTION
value=MERCEDES>MERCEDES</OPTION>
Any help will be appreceiated.
Thanks
Tony.
Message #2 by Imar Spaanjaars <Imar@S...> on Wed, 21 Feb 2001 17:50:54 +0100
|
|
ALWAYS do a Response.Write(strsql) before you open a recordset. That way
you can see what you are trying to execute, and what's causing the error.
In this case, add a space for ORDER, because your SQL now looks like where
make = 'AValue'ORDER by etc etc which of course will generate an error.
Also, it looks like you are trying to add to value for one WHERE clause,
right?? You can't do that. Specify the WHERE clause once, but use the
fieldname multiple time:
WHERE make = 'AValue' OR make = 'AnotherValue'
If the second value (Request("model")) should query for model, then change
the OR to AND and change the second make to model, like this:
WHERE make = 'AValue' AND model = 'AnotherValue'
Hope this helps,
Imar
At 12:33 PM 2/21/2001 -0800, you wrote:
>Hi,
>This is my code which is not working:
>
>Set rsRpt = Server.CreateObject("ADODB.Recordset")
>
>'strsql = "SELECT * FROM Orders where customerID ='" & frmUser & "'"
>strsql = "SELECT * from cars where make = '" & frmUser & "'"
> Request("model") &_
> "ORDER by model"
>
><TD><SELECT id=DropUser name=DropUser style="HEIGHT: 22px; WIDTH:
>88px"><OPTION selected value="BMW">BMW</OPTION><OPTION
>value=MERCEDES>MERCEDES</OPTION>
>
>Any help will be appreceiated.
>Thanks
>Tony.
Message #3 by "Wally Burfine" <oopconsultant@h...> on Wed, 21 Feb 2001 18:33:36 -0000
|
|
use the ampersand underscore on the strsql assignemnt:
strsql = "...'" & ... & "'" & _
Regards
Wally
>From: "Anthony Ekperechi" <tonycom1@h...>
>Reply-To: "ASP Databases" <asp_databases@p...>
>To: "ASP Databases" <asp_databases@p...>
>Subject: [asp_databases] recordset query cars
>Date: Wed, 21 Feb 2001 12:33:08 -0800
>
>Hi,
>This is my code which is not working:
>
>Set rsRpt = Server.CreateObject("ADODB.Recordset")
>
>'strsql = "SELECT * FROM Orders where customerID ='" & frmUser & "'"
>strsql = "SELECT * from cars where make = '" & frmUser & "'"
> Request("model") &_
> "ORDER by model"
>
><TD><SELECT id=DropUser name=DropUser style="HEIGHT: 22px; WIDTH:
>88px"><OPTION selected value="BMW">BMW</OPTION><OPTION
>value=MERCEDES>MERCEDES</OPTION>
>
>Any help will be appreceiated.
>Thanks
>Tony.
|
|
 |