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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double search criteria

Status
Not open for further replies.
Nov 15, 2002
13
CA
I am having trouble with SQL when I want to check two text boxes. It gives me a syntax error. Below is the code that I have.

(All in one line)
oRS.open "SELECT * FROM tbldata WHERE DealNum=" & Request.Form("Deal") AND WHERE Sequence=" & Request.Form("Sequence") , "DSN=WiresASP"
 
You need to have
'& " '
before the "Request.Form("Deal")" in your SQL statement

oRS.open "SELECT * FROM tbldata WHERE DealNum=" & Request.Form("Deal") & " AND WHERE Sequence=" & Request.Form("Sequence") , "DSN=WiresASP"
 
You may also want to remove the second where from the statement:
Code:
oRS.open "SELECT * FROM tbldata WHERE DealNum=" & Request.Form("Deal") & " AND Sequence=" & Request.Form("Sequence") , "DSN=WiresASP"
If DealNum is a string value in the db, than you need the single quotes like mentioned above:
Code:
oRS.open "SELECT * FROM tbldata WHERE DealNum='" & Request.Form("Deal") & "' AND Sequence=" & Request.Form("Sequence") , "DSN=WiresASP"

If Sequence is a string you would need single quotes on that:
Code:
oRS.open "SELECT * FROM tbldata WHERE DealNum=" & Request.Form("Deal") & " AND Sequence='" & Request.Form("Sequence")&"'" , "DSN=WiresASP"
Like so.

I'm assuming you can figure out the both by yourself, I only reposted the single quotes issue to make sure you didn't doubt it from the previous post and assume removal of the extra where would do it for you (for whatever reason).
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top