-
Mar 11th, 2015, 09:11 AM
#1
Thread Starter
Addicted Member
bindingsource filter 2 columns
Hello dear vb friends,
as the title says, i want to search in 2 columns not only in one. i didnt figure out what i have to do. this is my code what works fine but it only searcheds in "Name" Column.
DtKundenBindingSource.Filter = "Name like '" & tb_suchen.Text & "%'"
.
I tried this but error appears.
DtKundenBindingSource.Filter = "Name like '" & tb_suchen.Text & "%'" And "Street like '" & tb_suchen.Text & "%'"
-
Mar 11th, 2015, 09:44 AM
#2
Re: bindingsource filter 2 columns
Code:
DtKundenBindingSource.Filter = String.Format("Name Like = '{0}' AND Street Like = '{1}'", tb_suchen.Text & "%" , tb_suchen.Text & "%")
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
-
Mar 11th, 2015, 04:18 PM
#3
Thread Starter
Addicted Member
Re: bindingsource filter 2 columns
I had to remove the = in your code now it works. also i changed AND to Or because i want to search in column NAme OR Strasse.This is my code now. Thanks.
Code:
DtKundenBindingSource.Filter = String.Format("Name Like '{0}' or Strasse Like '{1}'", tb_suchen.Text & "%", tb_suchen.Text & "%")
-
Mar 11th, 2015, 06:16 PM
#4
Re: bindingsource filter 2 columns
It's a small thing but why concatenate Strings when you're already using String.Join?
Code:
DtKundenBindingSource.Filter = String.Format("Name Like '{0}%' or Strasse Like '{1}%'", tb_suchen.Text, tb_suchen.Text)
-
Mar 12th, 2015, 03:33 AM
#5
Re: bindingsource filter 2 columns
I had to remove the = in your code now it works.
Doh of course the equals shouldn't be there i did that in a bit of a rush.
It's a small thing but why concatenate Strings when you're already using String.Join?
I didn't even think about doing that JMC but your right its nicer and neater
Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|