0

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?

Community
  • 1
  • 1
Dany
  • 131
  • 3
  • 17

1 Answers1

3

Use '' (this is 2 ' characters).

DataTable.select("text = 'Hello''World'")
Saty
  • 22,443
  • 7
  • 33
  • 51
Bradley Uffner
  • 16,641
  • 3
  • 39
  • 76