Dany
Dany

Reputation: 131

DataTable.Select with ' (single quote) Character in the query vb.net

I have a string like "Hello'World" and a DataTable with some records in it. One of those records is "Hello'World".

The problem is, when I do a .Select in the DataTable, it only tries to search for the "Hello" part and throws an error on "World" because it interprets the ' (single quote) like the closing quote on sql.

DataTable.Select("text = 'Hello'World'")

I have gone through msdn doc, and it says I can escape some characters with [] brackets or f.slashes \, but I just can't figure out: .select("text = 'Hello[']world'")

I've done some reading: Verbatim in vb - c# and "jmcilhinney" explains it really well. BUT, it did not answer my question for what I want to do. In stackoverflow.com, a same question is posted but in c#, but I can't find a way to use @ in vb.

Can you please redirect me to more doc, examples or any one of you have ever encountered this problem?

Upvotes: 0

Views: 7873

Answers (1)

Bradley Uffner
Bradley Uffner

Reputation: 16991

Use '' (this is 2 ' characters).

DataTable.select("text = 'Hello''World'")

Upvotes: 3

Related Questions