Dear Honors
I'm using Sql server database..
I stored the varchar field with Some Punctuation Symbol like
SPENCER'S PLAZA...
It stores fine.. But when I read from the database it shows the error because of the punctuation symbol error..
How to read the value with punctuation symbol from sql database?..
Kindly check the following query
customername=spencer's plaza
select customername from tablename where customername='spencer's plaza'
Thanks in Advance,
Regards,
Loading
Prabhu RajaPosted Oct 1, 2011, 8:44 AM
customername= @"spencer's plaza";
select Customername from tablename customerName=customername
Satish BhatPosted Oct 1, 2011, 5:09 AM
But when retrieving it is throwing an error in the criteria expression. The reason for the failure is the single quote which is part of the string in your WHERE criteria column (when customername is "spencer's plaza"). The SQL engine will try to interpret your SQL statement and will consider the single quote inside the string as the end of that string. The remaining part of the SQL statement (in your case it is "s plaza" cannot be interpreted correctly, thus you are getting an error.
The solution is by replacing all single quotes in your string with two single quotes. When we have two single quotes together, they are interpreted by SQL as one single quote.
Veeramanikandan DhanabalanPosted Oct 1, 2011, 4:56 AM
i stored the value in customername field like above format...
select Customername from tablename customerName='customername'
Satish BhatPosted Oct 1, 2011, 2:58 AM
e.g. SELECT CustomerName FROM TableName WHERE CustomerName = 'spencer''s plaza'
If you are using ADO.NET Command Object with Parameterized Query, it automatically solves the problem (you don't have to escape the single quotes)