If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Search from ddl which have more than 2 options

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-02-06, 23:13
Cuttie0506 Cuttie0506 is offline
Registered User
 
Join Date: Jan 2006
Posts: 44
Search from ddl which have more than 2 options

I have several dropdown list. For each dropdown list, i can select more than 1 option.

For the code below, currently i can only get results if i search 1 option or no option from each ddl.

If 1 criteria i select 2 options, i will get results from both.

So the inside operator is an 'OR'

So i use split to split the options for each criteria. But h0w can i use that to search what i want?


Code:
	If request.form ("status") <> "" Then
		strSentence1 = request.form("status")
	ElseIf request.form("status") = "" Then
		strSentence1 = ""
	End If

	strSen1 = Split(strSentence1, ", ")

	If request.form ("email") <> "" Then
		strSentence2 = request.form("email")
	ElseIf request.form("email") = "" Then
		strSentence2 = ""
	End If

	If request.form ("action") <> "" Then
		strSentence3 = request.form("action")
	ElseIf request.form("action") = "" Then
		strSentence3 = ""
	End If

	If request.form ("severity") <> "" Then
		strSentence4 = request.form("severity")
	ElseIf request.form("severity") = "" Then
		strSentence4 = ""
	End If

	If request.form ("week") <> "" Then
		strSentence5 = request.form("week")
	ElseIf request.form("week") = "" Then
		strSentence5 = ""
	End If

	If request.form ("class") <> "" Then
		strSentence6 = request.form("class")
	ElseIf request.form("class") = "" Then
		strSentence6 = ""
	End If

	If request.form ("bu") <> "" Then
		strSentence7 = request.form("bu")
	ElseIf request.form("bu") = "" Then
		strSentence7 = ""
	End If

	If request.form ("server") <> "" Then
		strSentence8 = request.form("server")
	ElseIf request.form("server") = "" Then
		strSentence8 = ""
	End If
'******************************************************************

	Set rs_vServerName = Server.CreateObject("ADODB.Recordset")
	rs_vServerName.ActiveConnection = MM_dsprms_STRING

		sqlString = "Status LIKE ('"& strSentence1 &"%') AND Recipient LIKE ('"& strSentence2 &"%') AND Action_Taken LIKE ('"& strSentence3 &"%') AND Severity LIKE ('"& strSentence4 &"%') AND Week LIKE ('"& strSentence5 &"%') AND Class LIKE ('"& strSentence6 &"%') AND Business_Unit LIKE ('%"& strSentence7 &"%') AND Server_Name LIKE ('%"& strSentence8 &"%')"		
			
		sqlString = "SELECT * FROM Security_Vulnerability WHERE " & sqlString & "ORDER BY ID"

		rs_vServerName.Source = sqlString
		rs_vServerName.CursorType = 0
		rs_vServerName.CursorLocation = 2
		rs_vServerName.LockType = 1
		rs_vServerName.Open()


		If rs_vServerName.eof Then 
			
			response.redirect ("No_Query.asp")

		End If

		ServerArray = rs_vServerName.GetRows
		
		
		'rs_vServerName.Close()
Reply With Quote
  #2 (permalink)  
Old 02-06-06, 21:35
Cuttie0506 Cuttie0506 is offline
Registered User
 
Join Date: Jan 2006
Posts: 44
Can ani1 help me solve this problem? This problem quite important to me.. Thanx!
Reply With Quote
  #3 (permalink)  
Old 02-07-06, 03:39
kropes2001 kropes2001 is offline
Registered User
 
Join Date: Nov 2005
Location: Honolulu HI
Posts: 118
Ok..
i do not see an OR anywhere in that code...

second..
you can eliminate all of those if, then else if, end if statements...
all un necessary.
Code:
		strSentence1 = request.form("status")
	strSen1 = Split(strSentence1, ", ")
		strSentence2 = request.form("email")
		strSentence3 = request.form("action")
		strSentence4 = request.form("severity")
		strSentence5 = request.form("week")
		strSentence6 = request.form("class")
		strSentence7 = request.form("bu")
		strSentence8 = request.form("server")
does the exact same thing.
you are testing NULL on each field. therefore when you set the data, if the form filed is nuill, it will end up being null there too.

all your original code is logically correct, but completely irrelevant..
__________________
.
.
http://www.GetMySiteOnline.com - Can you help me Get My Site Online ? (Yes. That is EXACTLY what we do.)

http://www.GetMySiteOnline.com/FightingSpam/
__________________________
caeli enarrant gloriam Dei !
Reply With Quote
  #4 (permalink)  
Old 02-07-06, 04:08
Cuttie0506 Cuttie0506 is offline
Registered User
 
Join Date: Jan 2006
Posts: 44
Okay, thanx for your reply..

Ya, there's no OR inside my sql statements, because i don't know where i should put it..

and ya, what you mean by completely irrelevant?
Reply With Quote
  #5 (permalink)  
Old 02-07-06, 04:12
kropes2001 kropes2001 is offline
Registered User
 
Join Date: Nov 2005
Location: Honolulu HI
Posts: 118
irrelevant... un necessary, redundant, repetative.

your stuff (the if then's) work.. but not necessary at all.
__________________
.
.
http://www.GetMySiteOnline.com - Can you help me Get My Site Online ? (Yes. That is EXACTLY what we do.)

http://www.GetMySiteOnline.com/FightingSpam/
__________________________
caeli enarrant gloriam Dei !
Reply With Quote
  #6 (permalink)  
Old 02-07-06, 04:39
Cuttie0506 Cuttie0506 is offline
Registered User
 
Join Date: Jan 2006
Posts: 44
o, okay, what u mean is my (if else) statements..

But the thing i want to solve is my sql statement, the 'OR' and 'AND' operators.

But thanx for telling me about the (if else) cos i didn't realise it initially.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On