Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BindingSource.Filter with Apostrophe

Status
Not open for further replies.

Kliot

Programmer
Jan 10, 2003
622
US
I'm trying to filter a bindingSource but I get an error when the filter string has an apostrophe in it.

eg:

dim ln as string = TbxLastName.text
BindingSource.Filter = "LastName like '" & ln & "%'"

This works fine unless the last name has an apostrophe in it, I tried adding a double apostrophe ln.replace("'", "''")but it still doesn't work. I get the error message

"The expression contains an invalid string constant: '."

Any suggestions?
Perrin

 
My bad, I tried it again this morning, this time correcting the trypo and it works great
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top