How to store the string with single quote in Microsoft SQL Server CE 2.0 using C# CF programme

  • Thread starter Thread starter micmic
  • Start date Start date
M

micmic

Deear all experts,

In the MySQL, we can use escape character '\' to save the STRING WITH
single quote into database (eg. we would like to insert into table
"tbl_ABC"with the string ab'c, we can use the following SQL query to insert
into database : Insert into tbl_ABC VALUES ('ab\'c'); ). Also there is some
functions in mySQL api so that we can save the single quote into MySql
database using C programme. But it seems that i cannot do so in the PDA
using Microsoft SQL Server CE 2.0. How to save the single quote string using
SQL for Microsoft SQL Server CE 2.0 . Is there any functions in C# to save
the single quote string into database ?

Best wishes,
Michael
 
micmic said:
In the MySQL, we can use escape character '\' to save the STRING WITH
single quote into database (eg. we would like to insert into table
"tbl_ABC"with the string ab'c, we can use the following SQL query to insert
into database : Insert into tbl_ABC VALUES ('ab\'c'); ). Also there is some
functions in mySQL api so that we can save the single quote into MySql
database using C programme. But it seems that i cannot do so in the PDA
using Microsoft SQL Server CE 2.0. How to save the single quote string using
SQL for Microsoft SQL Server CE 2.0 . Is there any functions in C# to save
the single quote string into database ?

As with everything else: don't put the parameter values directly into
your SQL command. Use parameterised queries/updates/inserts/deletes,
and set the value of the parameter. The driver will then take care of
making sure the data is quoted if necessary.
 
Dont know about SQL Server CE 2.0 - but did you try the old fashion SQL way?

INSERT INTO tbl_ABC VALUES ('ab''c') - this is double single-quote there
case you missed it
 
Back
Top