954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

IFF is not null query

Hi all I m trying to filter a sql db with many filter criteria which inert the user in textboxes .. i ve tryed this query

query = "Select * from T_INCIDENTS1 where IFF (txtPostcode.text is notNull) then Incident_Postcode='" & txtPostcode.Text & "') and iff (txtDMA.text is notNull) then Incident_DMA='" & txtDMA.Text & "')  "

but there is error near 'is'

can i use a query like this one? it would help me?

skran
Light Poster
43 posts since Nov 2011
Reputation Points: 19
Solved Threads: 2
 

hello !

you are adding txtPostcode.text and txtDMA.text in your Query , this totally wrong . you are using totally wrong logic for this query , can you please tell me what you want to get from this query , well you can do like this

dim Query  as string 
Query = "Select * from T_INCIDENTS1 where 1=1"
'now for example you have 2 textboxes , txt1,txt2 , for you filter
if txt1.text<>"" then
Query = Query & " And IFF (txtPostcode.text is notNull) then Incident_Postcode='" & txt1.Text & "')"
end if
if txt2.text<>"" then
Query = Query & " and iff (txtDMA.text is notNull) then Incident_DMA='" & txt2.Text & "') "
end if


Hope this will help you

Regards

waqasaslammmeo
Posting Pro in Training
472 posts since Aug 2011
Reputation Points: 38
Solved Threads: 82
 

it gives error near 'is'.
Something like that i ve tryed but i don t know why this problem exists.. ..:(

skran
Light Poster
43 posts since Nov 2011
Reputation Points: 19
Solved Threads: 2
 

also txt1 is txtPostcode and txt2 is txtDMA

skran
Light Poster
43 posts since Nov 2011
Reputation Points: 19
Solved Threads: 2
 

ohh :PPP sorry , i just solve your first issue how to set criteria , sorry again :P

now change your code like this

dim Query  as string 
Query = "Select * from T_INCIDENTS1 where 1=1"
'now for example you have 2 textboxes , txt1,txt2 , for you filter
if txt1.text<>"" then
Query = Query & " And Incident_Postcode='" & txt1.Text & "')"
end if
if txt2.text<>"" then
Query = Query & " and Incident_DMA='" & txt2.Text & "') "
end if


Hope this time it works fin9 :) sorry , again

Regards

waqasaslammmeo
Posting Pro in Training
472 posts since Aug 2011
Reputation Points: 38
Solved Threads: 82
 


Thank you thank you thank you!! So much!! :)

skran
Light Poster
43 posts since Nov 2011
Reputation Points: 19
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: