By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

Want to query

P: 19
Hi alL,

I have three dropdownlists for the filters the datagrid,
like QUALIFICATION, SKILLSET, STATUS..

now if i have selected on the dropdown of ddlqualification, but ddlstatus and ddlskilsets are in 'ALL' position, and same like that STATUS and SKILLSET.. i wrote the following query eith the if condition

Dim sSQL As String = (" Select ResumeId, FirstName + ' , ' + LastName AS Name, " & _
" Phone1, Email, Skillset, Qualification, case EmailFlag when '1' then 'Sent' when '0' then 'Not Sent' else 'Not Sent' end As EmailFlag,tblstatus.Status " & _
" from tblresume INNER JOIN tblstatus on tblstatus.Statusid=tblresume.status where 1=1")
connection.Open()

If skillset <> "0" Then
sSQL &= " And skillset like(" & skillset & ") "
End If

If Qualification <> "0" Then
sSQL &= " and Qualification like(" & Qualification & ") "
End If
If Status > 0 Then
sSQL &= " and tblresume.Status like(" & Status & ") "
End If
sSQL &= " ORDER BY Name ASC "



its working but my problem is, if i was selected qualification is 3 but the status is in ALL Position of my status dropdown,... i didnt get the exact anz... pls help me..


Thanks in advance..
Oct 4 '16 #1
Share this Question
Share on Google+
1 Reply


PhilOfWalton
Expert 100+
P: 1,430
I know nothing about SQLServer, but assuming there is a wildcard character (It's * in DOS & Access, and may be % in SQLServer), I think the statements should be something like.

Expand|Select|Wrap|Line Numbers
  1. If skillset <> "0" Then
  2.     sSQL &= " And skillset like(" & skillset & ") "
  3. Else
  4.     sSQL &= " And skillset like % "
  5. End If
  6.  
Where % is whatever wildcard is recognised.

Wild Guess

Phil
Oct 4 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.