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?

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

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

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

This question has already been answered. Start a new discussion instead.