GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  ASP.NET
Go To First  |  Previous Question  |  Next Question 
 ASP.NET  |  Question 13 of 164    Print  
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.


  
Total Answers and Comments: 3 Last Update: April 18, 2007     Asked by: sudhagar 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: karthik
 
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

Above answer was rated as good by the following members:
dainy_patel
March 07, 2006 07:18:29   #1  
karthik        

RE: i am searching a record in datagrid.if i enter any...
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
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
May 15, 2006 23:00:07   #2  
orion Member Since: May 2006   Contribution: 5    

RE: i am searching a record in datagrid.if i enter any...
Replace the single quote with two single quote.
 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
April 18, 2007 18:20:20   #3  
Carol Seaton        

RE: i am searching a record in datagrid.if i enter any...
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!

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape