Apostrophe in DataTable.Select Statement

grip003

Well-known member
Joined
Sep 2, 2004
Messages
89
Location
North Carolina
I am trying to use the DataTable.Select statement and the selection criteria is a string that contains an apostrophe. It looks like this
Code:
DataRow[] rows = ds.Tables["MyTable"].Select("Invoice=" + invoice_num + "");
the invoice_num is a string that holds @"tests inv".

I have tried setting invoice_num=@"test[]s inv" and invoice_num=@"test\s inv" but that doesnt work either. Can anyone help me on this?
 
I ran into a similar problem using classic ASP and MS Access. I did something along these lines.

C#:
//For insertion to db
str.Replace("","") //Replace a single quote with two single quotes

//For retrevial from db
str.Replace("","") //Replace two single quotes with a single quote
 
Back
Top