Question Locked

SQL in ASP page, database search

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi to all,

I have an ASP page that has 10 fields (drop-down menus) it is a sort of a form. Depending on what you choose, the information will extracted from the DB. Note that you have the option either choosing all the ten fields or even one, or two , or three.

My page now contains only 4 fields and it is working perfect. My code has about 16 If statements in order to handle all scenarios and possibilities. In other words, some users will fill up one field and some will fill 9 or 10. My question is there any other ways to write the queries so that I do not have to write a lot of If statements. I am talking about more than 800 If statements since there are 10 fields to fill so the number of the scenarios and possibilities are very very very large. Please advise if you have any suggestions. I appreciate your help and assistance.

any further information needed will be provided...
Thanks and regards...
Khaled

6 replies

by jgarcia102066

If you post your current IF statement with the 4 fields, I might have enough information to give you a more efficient approach.

by kmosli

The four fields with the IF statements:

set conn=Server.CreateObject("ADODB.Connection")

conn.Provider="Microsoft.Jet.OLEDB.4.0"

conn.Open "C:/Inetpub/wwwroot/Database/scholarship_db.mdb"

set rs =Server.CreateObject("ADODB.recordset")

rs.Open "SELECT majors FROM Major", conn

student_major=request.form("majors")

%>

by larryd4

I can't see why you would need an if statement, with the info you provided.

Such as if I had 4 dropdowns/lists etc. that allowed you to choose 10 options each, that will be used to query.

My sql would be something like
objRS.Filter = "field1 LIKE" & listbox1 & "field2 LIKE" * listbox2 & "field3 LIKE" & listbox3 & "field4 LIKE" & listbox4

by kmosli

Hi,

Thanks. I do not know if I am explaining myself correctly. I have 10 fields (drop down lists) on the web page. The user has the option to select either one field (drop menu list) in order to receive information from the database. OR you can choose 5 fields out of ten and then select in order to get to the database. So that's way I figured out that 4 fields need 16 scenarios, then 10 fields will need 1000 or so scenarios. Thanks again and I appreciate your help.

This discussion is closed to new replies.