grip003 Posted October 24, 2005 Posted October 24, 2005 I am trying to use the DataTable.Select statement and the selection criteria is a string that contains an apostrophe. It looks like this DataRow[] rows = ds.Tables["MyTable"].Select("Invoice='" + invoice_num + "'"); the invoice_num is a string that holds @"test's inv". I have tried setting invoice_num=@"test[']s inv" and invoice_num=@"test\'s inv" but that doesn't work either. Can anyone help me on this? Quote
Nate Bross Posted October 24, 2005 Posted October 24, 2005 I ran into a similar problem using classic ASP and MS Access. I did something along these lines. //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 Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
grip003 Posted October 24, 2005 Author Posted October 24, 2005 Thanks Nate, that worked. I didn't know I needed a double ' instead of a \' or something else. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.