Solved

Super Urgent ASP WhereClause question

Posted on 1998-12-16
6
211 Views
Last Modified: 2013-12-25
hi,
I have a asp question.

I want a search form (i will make it simple here) with 2 input query.
say City, State.
I click on Submit , the criteria strings will be passed to server and run a sql statement and returns the result.
I know how to pass one parameter but don't know how to pass two parameters.

How can I do that?

Please forward any simple sample code and I will granted with 150 points

Thank you very much and have a nice day!

ny971181
0
Comment
Question by:ny971181
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:rajgn
ID: 1857300
What do you mean by passing parameters? Do you mean passing values of City, State to the .asp(from a form) or passing the values as parameters to a stored procedure? can you elaborate this?
0
 
LVL 1

Author Comment

by:ny971181
ID: 1857301
I mean pass them to the .asp file form a form.
I don't use stored procedure in sql server.

thanks

0
 
LVL 1

Expert Comment

by:rajgn
ID: 1857302
Hey ny971181!

Is this question different from the other one?
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 6

Accepted Solution

by:
PBall earned 100 total points
ID: 1857303
<searchform.asp>
<html>
:
<form name=frmSearch action='search.asp' method=post>
<input name=txtCity value="">
<select name=selState>
:
<option value='FL'>Florida
:
</select>
:
<input type=submit name=btnNav value='Search'>
</form>
:
</html>

<search.asp>

<%
option explicit

dim city, state

city = request("txtCity")
state = request("selState")
:
strSQL = "SELECT ..... FROM Blah WHERE City = '" & city & "' AND State = '" & state & "' ORDER BY ...."

set rs = server.createobject("adodb.recordset")
rs.open strSQL,"databaseDSN"
:
do while not rs.eof
:
:
  rs.movenext
loop
:

is that what you want?
0
 
LVL 1

Author Comment

by:ny971181
ID: 1857304
In the case you mention, you won't get the right recordset if you don't put in any state because the sqlstatement still has the state = "" in it.
any better idea?


0
 

Expert Comment

by:MagicJ
ID: 1857305
I think u can try this
This is an addition to PBall's answer

dim firstCriteria
dim secCriteria

city = request("txtCity")
state = request("selState")
firstCriteria = ""
secCriteria = ""
if city<> "" then
   firstCriteria= " City = '" & city & "' "
end if
if state <> "" then
   if firstCriteria <> "" then
      secCriteria = " AND State = '" & state & "' "
   else
      secCriteria = " State = '" & state & "' "
   end if
end if

strSQL = "SELECT ..... FROM Blah WHERE " & firstCriteria & secCriteria & " ORDER BY ...."

0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to dynamically set the form action using jQuery.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question