Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

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

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...