473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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

Nov 16 '05 #1
3 11216
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
"micmic" <bi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 16 '05 #2
micmic <bi**********@hotmail.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
thx, i have tried it and it works. Thanks a lot =)
"Jon Skeet [C# MVP]" <sk***@pobox.com> ???
news:MP************************@msnews.microsoft.c om ???...
micmic <bi**********@hotmail.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: matvdl | last post by:
I have a system that was originally developed in asp - the pages are saved in SQL (there are over 10,000 pages) and saved to a temp directory in the server when requested by a client. I have...
3
by: ExclusiveResorts | last post by:
Can the CallContext be used reliably for storing request specific data? We are developing an application library that uses the CallContext to keep an IdentityMap (hashtable of business objects...
3
by: Solution Seeker | last post by:
I want to Store the String value with Single Quotes in the Field of Database where if i try to Store the String value with Single Quotes (as it is) then it is throwing the error as SQL String...
11
by: c676228 | last post by:
Hi everyone, I am just wodering in asp program, if there is anybody writing store procedure for inserting data into database since there are so many parameters need to be passed into store...
12
by: arnuld | last post by:
in C++ Primer 4/3 Lippman says in chapter 3, section 3.3.1: vector<stringsvec(10); // 10 elements, each an empty string here is the the code output & output from my Debian box running "gcc...
2
by: JRoughgarden | last post by:
After a customer decides to buy a shopping list, there is generally a need to store/insert one master record and a variable number of child detail records, preferably all wrapped in a transaction....
8
by: Merk | last post by:
I'm looking for a safe and maintainable way to store connection string info (connecting to SQL Server 2005 from .NET 2.0 Windows Forms client app); things like server name or IP address and...
13
by: Jennifer.Berube | last post by:
well I'm not sure how to go about making my SQL connection string... The code below is what I need to replace with my SQL connection...I just don't know if that code is for DSN or access... I...
5
by: jc | last post by:
Hi. I am in a situation with an engineering application involving monitoring of press operations. This involves storage of numbers for both an X and Y arrays. The number of element within the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.