I am passing some query like this:
"select * from Item where Item_Name like '" + GridViewItem.Rows[0].Cells[1].ToString() + "'";
Item Name contains a single quote, so when I am passing the above error is coming.
Suggest me some answers...
Thank You...

Sunny SharmaRank #223 · 11.1K reputationPosted Oct 9, 2013, 12:03 AM EDT
check the value returned from GridViewItem.Rows[0].Cells[1].ToString() as it may contain any quotes inside.
HTH :)
shibasankar behera102 reputationPosted Oct 9, 2013, 12:33 AM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Oct 9, 2013, 12:36 AM EDT
Try this:
"select * from Item where Item_Name like '" + GridViewItem.Rows[0].Cells[1].ToString().Replace("'","")+ "'";
VulpesRank #55 · 29.2K reputationPosted Oct 9, 2013, 12:41 AM EDT
"select * from Item where Item_Name like '" + GridViewItem.Rows[0].Cells[1].ToString().Replace("'", "''") + "'";