I have a GridView
where I will display the data in my table. In my table, I have:
FIELD ITEM
=======
Fruit"s
Vegetable"s
That's how I saved it in my table. So in saving, I'm using Replace("'", "\\"");
but my problem is now how should I display it again in single quote.
This is how I saved it
SQLCMD = "INSERT INTO Table(fldItem) VALUES ('" + _strItem.Replace("'", "\"") + "')";
but when I tried to used it in code-behind:
string _qry = "SELECT Replace(fldItem,'"','''') FROM Table";
There's an error saying
Too many characters in character literal
You need to escape the "
with a backslash, \\"
.
So,
string _qry = "SELECT Replace(fldItem,'\"','''') FROM Table";
OR
string _qry = @"SELECT Replace(fldItem,'""','''') FROM Table";
Test
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.