I am searching a record in datagrid.if i enter any value it display record not found,if the record is not there.but i enter Apostrophe it is showing error(Cannot perform 'Mod' operation on System.String and System.String)....how to clear this bug.....

I need answer from someone.

Showing Answers 1 - 5 of 5 Answers

karthik

  • Mar 7th, 2006
 

Do string.Replace("'","") before added to database then it will be easy for u or if u want to search also follow the same procedure

Carol Seaton

  • Apr 18th, 2007
 

Hi I came across a similar situation before.
The problem is apostrophes are not allowed in sql statements. For example, if you are making a selection on your database looking for " Peter O'connor " the apostrophe will be read by sql as and of string livin "connor" as a non recognised word.

There is a very simple solution to overcome this... when adding or retrieving your string from the database add an extra apostrophe to your string. That means that your field in the database still will contain the apostrophe but you avoid de error. to do that use the replace function on your string... Work as a treat!

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions