Problem in Searching Multiple selects from a DropDown in Classic ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Samant
    New Member
    • Aug 2010
    • 4

    Problem in Searching Multiple selects from a DropDown in Classic ASP

    Hello Thr. I know I am doing it correctly but, missing some very minor thing. I have a form whr I have 5 drop down lists and searching th ose values from a database. I already have entered some values in my database. When I try to run this below mentioned sql query with just one subskill, it runs fine. But when I run it with multiple subskills, it doesnt come up with any result. It says no record found. Please help me.

    Below mentioned is my sql query.
    Code:
    t1=request("skill")
    t2=request("subskill")
    
    t4=request("simple")
    t5=request("medium")
    t6=request("complex")
    
    
    
    
    if t1 <> "" and t2 <> "" and t4 <> "" and t5 <> "" and t6 <> "" then
    
    If InStr(t2,",") > 0 Then
    arrTerms = Split(t2,",")
    
    For x = 0 to UBound(arrTerms)
    
    login = "(select TOP "&t4&" * from skills where dept Like '%"&t1&"%' and desg Like '%"&arrTerms(x)&"%' and rating='simple')"
    'login = login & "UNION (select TOP "&t5&" * from skills where dept Like '%"&t1&"%' and desg Like '%"&arrTerms(x)&"%' and rating='medium')"
    'login = login & "UNION (select TOP "&t6&" * from skills where dept Like '%"&t1&"%' and desg Like '%"&arrTerms(x)&"%' and rating='complex')"
    
    If x < UBound(arrTerms) Then 
    login = login & " AND "
    End If
    
    Next 'x
    'login = login & " ORDER BY rating ASC;"
    
    else 
    login="(select TOP "&t4&" * from skills where dept Like '%"&t1&"%' and desg Like '%"&t2&"%' and rating='simple' ORDER BY Rnd(Len([question]))) UNION (select 
    
    TOP "&t5&" * from skills where dept Like '%"&t1&"%' and desg Like '%"&t2&"%' and rating='medium' ORDER BY Rnd(Len([question]))) UNION (select TOP "&t6&" * 
    
    from skills where dept Like '%"&t1&"%' and desg Like '%"&t2&"%' and rating='complex' ORDER BY Rnd(Len([question])))"
    
    End If
    End If
    Last edited by jhardman; Aug 6 '10, 03:46 PM. Reason: added code tags
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    print out your final query (response.write login) with one skill and with multiple skills and compare them. 95% of the time you will see a mistake at this point.

    Second, run both of these queries through a query analyzer and see if they return the expected results. If it doesn't, then this is an issue with your SQL.

    Jared

    Comment

    Working...