473,800 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"wi th 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 11244
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**********@h otmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.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"wi th 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**********@h otmail.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"wi th 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.co m>
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.co m> ???
news:MP******** *************** *@msnews.micros oft.com ???...
micmic <bi**********@h otmail.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"wi th 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.co m>
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
2970
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 updated this system and changed the pages that are saved to the server as aspx - everything works fine and pages can be served - but Its not impossible for a single client to request 100 plus pages in one session - as each page is requested it is...
3
2813
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 that have been loaded from the DB) and a collection of business objects that have been modified during the current request. These object maps need to be globally visible throughout a request and expire at the end of it. The maps are accessed using...
3
2864
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 Truncated. so we need a solution to store and retrieve user Entered value along with single quotes into the Database. i am using the String variable to frame the Qry(that is then passed to Database for execution) which is as follows
11
4382
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 procedure(assume there are many columns in the table). I need to insert data into two separate tables, the relation between these two tables is 1 row of data in table1 could have multiple rows in table2 related to table1, but if the data insertion into...
12
5718
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 3.3.5": #include <iostream> #include <vector>
2
1563
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. There are lots of ways to do this and I am wondering if anyone knows which is most efficient. One approach is to use ADO.NET's transaction capabilities, define single-record insert procs for the master and detail tables, and call the detail...
8
12682
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 database name. I need to provide the client application with this info for connecting to both a test SQL Server and a production server. I would prefer to NOT hard-code this info into the client application, and App.Config seems rather unsafe as the...
13
2850
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 don't want to use DSN just a connection string...help? function GetConnection() const DSN = "membershipdb" const UID = "webuser"
5
4076
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 arrays varies slightly but should be identical for a singular press operation. One approach is to store an element in a row. This would be 6000 rows (3000 elements/axis * 2). This seems excessive for a single operation. Also, I have no...
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.