Click here to Skip to main content
15,888,293 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more: , +
Hi all,

I want to insert a string with single quotations like this 'StringName' in SqlCE.

any one have idea? please share with me.

Thanks,
Balu.
Posted

Yes it is. Sounds like you may concatenate strings to you SQL statement. Don't do that. Instead use SqlParameter[^]. With parameters you won't have any problems with quotation marks
 
Share this answer
 
Comments
Balu199 17-Dec-11 1:16am    
can you give an small example how to insert.

Thanks,
Balu
Wendelius 17-Dec-11 1:22am    
There are lots of examples in net. For example: http://www.dotnetperls.com/sqlparameter[^]
As I understood your question you want to have single quote in your string literals so use it double to distinguish it from the SQL command single quote , for example :

SQL
insert into names(name) values ('John') 


will insert John , but :

SQL
insert into names(name) values ('''John''') 


will insert 'John' .

or :

SQL
insert into names(name) values ('o''reilly') 


will insert o'reilly

Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900