Carmen

Carmen

  • NA
  • 11
  • 0

apostraphe SQLexception

Jul 24 2009 2:47 PM

I'm inserting and retreiving values from and SQL table to an ASP.net web application.
For inserting values i used .Replace("'", "''") to replace apostraphe's.
As a test I inserted strawberries' as a value and this worked. But when I try to retrieve this record using an SqlDataReader, i get a SQL exception message as follows:
Unclosed quotation mark after the character string 'strawberries''. Incorrect syntax near 'strawberries''.
The sql command I am using in the command.ExecuteReader() appears as follows:
"select * from table where fieldname = 'strawberries''"
How do I correct this error?

Answers (1)