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...
VulpesPosted Oct 9, 2013, 4:41 AM
"select * from Item where Item_Name like '" + GridViewItem.Rows[0].Cells[1].ToString().Replace("'", "''") + "'";
Sunny SharmaPosted Oct 9, 2013, 4:36 AM
Try this:
"select * from Item where Item_Name like '" + GridViewItem.Rows[0].Cells[1].ToString().Replace("'","")+ "'";
shibasankar beheraPosted Oct 9, 2013, 4:33 AM
Sunny SharmaPosted Oct 9, 2013, 4:03 AM
check the value returned from GridViewItem.Rows[0].Cells[1].ToString() as it may contain any quotes inside.
HTH :)