String with single quote not saved in DB


I tried to save the single quote within a string. But it always shows error. Find the solution for error on single quote within a string.

Learn the solution for error on single quote within a string


I tried to save the single quote within a string. But it always shows error.
And then I found the solution to that problem. That is, if you add another single quote near to that existing single quote, now you can store easily.


My existing query:

INSERT INTO Barrett(SNo,EleNo,EleName,Type,AttbNo,AttbName,AttbVal,StyleName,StyleType,LISFirst,LISLast,RefEleNo,RefEleName,RefEleType,RefAttbNo,RefAttbName,RefAttbVal,ConAttb,Tag,LibFile,LibItem,LblName,MasPage,LyrName,XMLVer,XPath,GroupStylePath,VarEle,GrpVar,LastVar,SizeAdj,Text1,Text2,Anchor) VALUES(42, 1, 'chapter', 'ROT', '', '', '', 'App' Head', 'P', 'L#RH', '', '', '', '', '', '', '', '', 'B', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');


Check the string App' Head. So this query was always displayed error message.

Soultion query:

INSERT INTO Barrett(SNo,EleNo,EleName,Type,AttbNo,AttbName,AttbVal,StyleName,StyleType,LISFirst,LISLast,RefEleNo,RefEleName,RefEleType,RefAttbNo,RefAttbName,RefAttbVal,ConAttb,Tag,LibFile,LibItem,LblName,MasPage,LyrName,XMLVer,XPath,GroupStylePath,VarEle,GrpVar,LastVar,SizeAdj,Text1,Text2,Anchor) VALUES(42, 1, 'chapter', 'ROT', '', '', '', 'App'' Head', 'P', 'L#RH', '', '', '', '', '', '', '', '', 'B', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '');


Comments

Author: kalyani26 Aug 2010 Member Level: Bronze   Points : 1

insert into s values (''' k')


Try This..........it gives 'k


Kalyani

Author: Alwyn Duraisingh26 Aug 2010 Member Level: Gold   Points : 1

This is not a wise idea to deal with.

while passing the parameter value for the stored procedure

Replace the single Quotes with "&rsquot;"

in the insert statement, replace the &rsQuot; value with the single quotes.

Author: arun kumar16 Sep 2010 Member Level: Silver   Points : 1

i think this is not a right way to pass the value directly into table... would like to suggest to use the parameter and your problem sort out very easily if you still facing this problem then send me your problem through mail myEmail: akdavid22@gmail.com
for your knowledge column in table always store the string value mean double quotes

Author: Ultimaterengan02 Oct 2010 Member Level: Gold   Points : 1

HI Friend,

Good stuff....

Continue to post such valuable articles in dotnetspider......

I tried this one its working fine.

Author: Roshan R Mhatre15 Nov 2011 Member Level: Silver   Points : 0

in C# pass this column name with
txtTextBoxName.Text.replace("'","''").tostring



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: