Dataview Rowfilter

G

Georg Schmelzer

Hi Ng,

need some help here. What's wrong with that dataview.rowfilter expression:


dtFliste.DefaultView.RowFilter = "Field1 Like '%" & strFV & "%'" & _
" AND Field2 Like '%" & strFS & "%'" & _
" AND Field3 Like '%" & strFT & "%'" & _
" AND Field4 Like '%" & strGW & "%'" & _
" AND Field5 Like '%" & strKu & "%'" & _
" AND Field6 Like '%" & strIb & "%'"



As this filter always returns an empty datatable?

Thanks a Lot.

G. Schmelzer
 
G

Guest

Georg Schmelzer said:
Hi Ng,

need some help here. What's wrong with that dataview.rowfilter expression:


dtFliste.DefaultView.RowFilter = "Field1 Like '%" & strFV & "%'" & _
" AND Field2 Like '%" & strFS & "%'" & _
" AND Field3 Like '%" & strFT & "%'" & _
" AND Field4 Like '%" & strGW & "%'" & _
" AND Field5 Like '%" & strKu & "%'" & _
" AND Field6 Like '%" & strIb & "%'"



As this filter always returns an empty datatable?

Thanks a Lot.

G. Schmelzer


Do any of your str* fields have leading or trailing blanks which may cause
no records to be selected?
 
J

Jay B. Harlow [MVP - Outlook]

Georg,
In addition to the other comments:

You are using AND, which means that all the conditions HAVE to be True!

Are you certain that ALL the conditions are true?

For example if you only match on Field1, do you get records?

Also can you use Debug.WriteLine to print out the RowFilter after you set
it? As that would show us what the RowFilter itself looks like (it would
help identify badly formed filters). Can you post what RowFilter contains
after you set it if its now obvious to you what the problem is.

Hope this helps
Jay
 
G

Georg Schmelzer

Hi,

I solved the Problem myself. I just took a stringbuilder and build a string
which contains only those parts of the filter that aren't empty.

But thank you anyway.


mfg G. Schmelzer
 
J

Jay B. Harlow [MVP - Outlook]

George,
Glad you got it to work...

I was actually concerned that it was the "parts you didn't need" that was
messing you up.

Thanks for letting us know.
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top