Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: ASP in SQL statement


Message #1 by jmusolini@y... on Fri, 20 Sep 2002 01:06:49
I have a form with two select fileds( Months, and Category) that my users 
can use to query data in my Access Database. When the user submits the 
form, the action.asp does the following:

"SELECT * FROM MyAccessTable WHERE Month = '" & Request("MonthOption") 
& "' AND Inventory = '" & Request("CategoryOption") & "'" 

 This is working. However I don't know what to do in order to query for 
all months for a specific Category or vise versa.

Can you please help me?
Message #2 by "Drew, Ron" <RDrew@B...> on Thu, 19 Sep 2002 23:05:52 -0400
Add a option (Y or N)  to prompt the user for all months and put a if
statement in the select.

"SELECT * FROM MyAccessTable WHERE Inventory =3D '" &
Request("CategoryOption") &_
"AND Month " &_
if Request("AllMonthOption") =3D "Y" then
    " BETWEEN 01 and 12"
else
    " =3D " & Request("MonthOption")
endif

-----Original Message-----
From: jmusolini@y... [mailto:jmusolini@y...]
Sent: Thursday, September 19, 2002 9:07 PM
To: ASP Web HowTo
Subject: [asp_web_howto] ASP in SQL statement

I have a form with two select fileds( Months, and Category) that my
users
can use to query data in my Access Database. When the user submits the
form, the action.asp does the following:

"SELECT * FROM MyAccessTable WHERE Month =3D '" & Request("MonthOption") 

& "' AND Inventory =3D '" & Request("CategoryOption") & "'"

 This is working. However I don't know what to do in order to query for
all months for a specific Category or vise versa.

Can you please help me?

---

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

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogramm
e
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogramm
e
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogramm
e
r-20
Message #3 by Vijay G <happygv@y...> on Thu, 19 Sep 2002 20:24:26 -0700 (PDT)
You can do it this way

Validate the forms in ASP and based on the Value that is available in the form fields, you can build the query to extract from the
DB.

Eg: If value of MONTH alone is given, then you query for all categories of that month.
IF Request.Form("MonthOption") IS GIVEN and VALID 
AND Request.Form("CategoryOption") IS NOT GIVEN
"SELECT * FROM MyAccessTable WHERE Month = '" & Request("MonthOption") 


If value of CATEGORY alone is given, then you query for all Months of that Category.
IF Request.Form("MonthOption") IS NOT GIVEN 
AND Request.Form("CategoryOption") IS GIVEN and VALID
"SELECT * FROM MyAccessTable WHERE Inventory = '" & Request("CategoryOption") & "'" 

If value of both MONTH and CATEGORY are given, then you query for specific month and specific category.
IF Request.Form("MonthOption") IS GIVEN and VALID 
AND Request.Form("CategoryOption") IS GIVEN and VALID
"SELECT * FROM MyAccessTable WHERE Month = '" & Request("MonthOption") 
& "' AND Inventory = '" & Request("CategoryOption") & "'" 

Cheers!!!
Vijay G

 jmusolini@y... wrote:I have a form with two select fileds( Months, and Category) that my users 
can use to query data in my Access Database. When the user submits the 
form, the action.asp does the following:

"SELECT * FROM MyAccessTable WHERE Month = '" & Request("MonthOption") 
& "' AND Inventory = '" & Request("CategoryOption") & "'" 

This is working. However I don't know what to do in order to query for 
all months for a specific Category or vise versa.

Can you please help me?

---


---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!

  Return to Index