Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2006
    Posts
    44

    Unanswered: 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()

  2. #2
    Join Date
    Jan 2006
    Posts
    44
    Can ani1 help me solve this problem? This problem quite important to me.. Thanx!

  3. #3
    Join Date
    Nov 2005
    Location
    Honolulu HI
    Posts
    119
    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.HawaiianHope.org
    Providing Technology services to non profit orgs, Homeless Shelters, Food Pantries, Clean And Sober Houses and more.
    To date we have given away over 900 free computers !
    __________________________
    caeli enarrant gloriam Dei !

  4. #4
    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?

  5. #5
    Join Date
    Nov 2005
    Location
    Honolulu HI
    Posts
    119
    irrelevant... un necessary, redundant, repetative.

    your stuff (the if then's) work.. but not necessary at all.
    .
    .
    http://www.HawaiianHope.org
    Providing Technology services to non profit orgs, Homeless Shelters, Food Pantries, Clean And Sober Houses and more.
    To date we have given away over 900 free computers !
    __________________________
    caeli enarrant gloriam Dei !

  6. #6
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •