473,513 Members | 2,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

data problems

Hi,

I am not sure if this the correct group to ask or not, but here it goes. I
am having problems inserting
data into MS SQL 2005 vai c#.

I have strings( varchar( 80 )), that have ' and " in them:

'Danny's Place'
' 1' 1/2" '

How do I get SQL in c# to take varchar with ' & " ?

I have found issues in creating column names with / & % as well. Any ideas?

Thanks,

Jerry
Feb 13 '07 #1
2 1242
use parameters or replace ' with '' (two of them) and " with ""
Parameters are the proper way to do it though.
e.g

SqlCommand sqlcom = new SqlCommand("insert into table1 (col1, col2) values
(@value1, @value2), new SqlConnection(constring);
sqlcom.Parameters.AddWithValue("@value1", "Danny's Place");
sqlcom.Parameters.AddWithValue("@value2", " 1' 1/2\"");

sqlcom.Connection.Open();
sqlcom.ExecuteNonQuery();
sqlcom.Connection.Close();
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Jerry" wrote:
Hi,

I am not sure if this the correct group to ask or not, but here it goes. I
am having problems inserting
data into MS SQL 2005 vai c#.

I have strings( varchar( 80 )), that have ' and " in them:

'Danny's Place'
' 1' 1/2" '

How do I get SQL in c# to take varchar with ' & " ?

I have found issues in creating column names with / & % as well. Any ideas?

Thanks,

Jerry
Feb 13 '07 #2
Hi,

See the other thread you posted.

"Jerry" <jp******@general-steel.comwrote in message
news:12*************@corp.supernews.com...
Hi,

I am not sure if this the correct group to ask or not, but here it goes.
I am having problems inserting
data into MS SQL 2005 vai c#.

I have strings( varchar( 80 )), that have ' and " in them:

'Danny's Place'
' 1' 1/2" '

How do I get SQL in c# to take varchar with ' & " ?

I have found issues in creating column names with / & % as well. Any
ideas?

Thanks,

Jerry

Feb 13 '07 #3

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

Similar topics

0
1410
by: Ken in Melbourne Australia | last post by:
For some Open Source (GPL licensed) programs that I am working on, I am trying to create some PHP routines for data handling with good security. The routines I have created for this are given...
3
3907
by: Claudio Grondi | last post by:
Is there an already available script/tool able to extract records and generate proper HTML code out of the data stored in the Wikipedia SQL data base? e.g. converting all occurences of ] to <a...
32
3190
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
14
7783
by: Steven T. Hatton | last post by:
I'm trying to write a program like hexel. I guess I could fish out the source for hexel and look at that, but for now I'm trying to figure out how I can do with with std::stringstream and...
6
2241
by: Michael | last post by:
Hi all, I'm a Bachelor in Computer Engineering, and going to study Masters (major in Knowledge-Based systems). I'm quite fascinated by the concept of data-mining and knowledge-based systems, and...
0
1284
by: Jesper Stocholm | last post by:
I am using the example as the basis for an application I am currently writing. The setup consists of two applications (client and server) that talk to each other thru TCP. I have no problems...
2
1674
by: Wolter Kamphuis | last post by:
Hi all, I've got a question, not really about PHP but this is the best audience. Is anybody aware of problems with Internet Explorer not sending any get/post/cookie data? I'm the webmaster of...
27
12997
by: ted benedict | last post by:
hi everybody, i hope this is the right place to discuss this weird behaviour. i am getting dynamically generated text or xml from the server side using xmlhttprequest. if the server side data is...
31
7700
by: aarklon | last post by:
Hi all, this is a question which i saw in a book typedef struct mall_li_header_ { int refcnt; uchar pool; uchar flag; ushort magic_no; char data;
2
2038
by: manugm1987 | last post by:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <style type="text/css"><!--...
0
7260
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,...
0
7537
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...
1
7099
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...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4746
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...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1594
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 ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
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...

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.