473,403 Members | 2,359 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,403 software developers and data experts.

decimal point changes to comma in INSERT Querystring

Friends

When I use a Querystring for insertdating data into a Tabel (going to
SQLserver)
the decimal pint changes to a comma. The result is that I get a system error
(which I can understand)

sSQL = "INSERT A,B INTO TABEL VALUES (aValue, BValue");
where A ="aaa"
and B = 12.5

is a string and B is a float.

the result is INSERT A , B INTO TABEL VALUES ( "AAA", 12,5); Now SQL Server
assumes 3 variables

How to solve this??
Regards
gerrit Esmeijer

Nov 16 '05 #1
4 8173
G.Esmeijer <ge****@nomail.nl> wrote:
When I use a Querystring for insertdating data into a Tabel (going to
SQLserver)
the decimal pint changes to a comma. The result is that I get a system error
(which I can understand)

sSQL = "INSERT A,B INTO TABEL VALUES (aValue, BValue");
where A ="aaa"
and B = 12.5

is a string and B is a float.

the result is INSERT A , B INTO TABEL VALUES ( "AAA", 12,5); Now SQL Server
assumes 3 variables

How to solve this??


Don't put the values into the SQL directly at all - use parameters, and
set the values of the parameters.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Are you using adhoc SQL, or typed parameters? You should be using typed
parameters.

That is, do not do this:
aSQL = "INSERT A,B INTO TABLE VALUES (" + aValue + ", " + bValue + ");";

Not only do you run into culture issues, as you are below, but there are
also HUGE security problems if somebody injects bad strings into aValue.

You should instead be using the SqlCommand class, and it's typed parameters.
It takes a little bit more code, but in the long run you'll have less
headaches.

Do something like:
aSQL = "INSERT A,B INTO TABLE VALUES (@A, @B);";
SqlCommand insCmd = new SqlCommand(aSQL, connection);
SqlParameter param1 = new SqlParameter("@A", System.Data.SqlDbType.NVarChar,
length);
param1.Value = aValue;
insCmd.Parameters.Add(param1);
SqlParameter param1 = new SqlParameter("@B", System.Data.SqlDbType.Int);
param1.Value = bValue;
insCmd.Parameters.Add(param2);

The above should be close, although I can't gurantee it will compile as
written. Look up the specific classes for more info.
--
Mike Mayer, C# MVP
mi**@mag37.com
http://www.mag37.com/csharp/
"G.Esmeijer" <ge****@nomail.nl> wrote in message
news:40**********************@dreader2.news.tiscal i.nl...
Friends

When I use a Querystring for insertdating data into a Tabel (going to
SQLserver)
the decimal pint changes to a comma. The result is that I get a system error (which I can understand)

sSQL = "INSERT A,B INTO TABEL VALUES (aValue, BValue");
where A ="aaa"
and B = 12.5

is a string and B is a float.

the result is INSERT A , B INTO TABEL VALUES ( "AAA", 12,5); Now SQL Server assumes 3 variables

How to solve this??
Regards
gerrit Esmeijer


Nov 16 '05 #3
Michael,

Thanks for taking the effort to help me out. I will try it and let you know
if it works.
The sucurity problems are not such an issue here. Im reading data from a
text-file which is then stored in SQLserver-table.

Regards
gerrit esmeijer


"Michael Mayer [C# MVP]" <mi**@mag37.com> schreef in bericht
news:Oi**************@TK2MSFTNGP11.phx.gbl...
Are you using adhoc SQL, or typed parameters? You should be using typed
parameters.

That is, do not do this:
aSQL = "INSERT A,B INTO TABLE VALUES (" + aValue + ", " + bValue + ");";

Not only do you run into culture issues, as you are below, but there are
also HUGE security problems if somebody injects bad strings into aValue.

You should instead be using the SqlCommand class, and it's typed parameters. It takes a little bit more code, but in the long run you'll have less
headaches.

Do something like:
aSQL = "INSERT A,B INTO TABLE VALUES (@A, @B);";
SqlCommand insCmd = new SqlCommand(aSQL, connection);
SqlParameter param1 = new SqlParameter("@A", System.Data.SqlDbType.NVarChar, length);
param1.Value = aValue;
insCmd.Parameters.Add(param1);
SqlParameter param1 = new SqlParameter("@B", System.Data.SqlDbType.Int);
param1.Value = bValue;
insCmd.Parameters.Add(param2);

The above should be close, although I can't gurantee it will compile as
written. Look up the specific classes for more info.
--
Mike Mayer, C# MVP
mi**@mag37.com
http://www.mag37.com/csharp/
"G.Esmeijer" <ge****@nomail.nl> wrote in message
news:40**********************@dreader2.news.tiscal i.nl...
Friends

When I use a Querystring for insertdating data into a Tabel (going to
SQLserver)
the decimal pint changes to a comma. The result is that I get a system

error
(which I can understand)

sSQL = "INSERT A,B INTO TABEL VALUES (aValue, BValue");
where A ="aaa"
and B = 12.5

is a string and B is a float.

the result is INSERT A , B INTO TABEL VALUES ( "AAA", 12,5); Now SQL

Server
assumes 3 variables

How to solve this??
Regards
gerrit Esmeijer



Nov 16 '05 #4
> The sucurity problems are not such an issue here. Im reading data from a
text-file which is then stored in SQLserver-table.

Since the price is so small, I would be concerned about security.
Two years from now someone will decide to get the strings from the
user and not realize all the implications.

--
Mihai
-------------------------
Replace _year_ with _ to get the real email
Nov 16 '05 #5

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

Similar topics

1
by: John Wheeler | last post by:
Hi, We upgraded the Windows ADC V8.1 to fixpack 5 on some Windows 2000 (Dutch Version) professional machines and something strange happened. When we select decimal columns in our queries the...
3
by: Kim Bundgaard | last post by:
Hi Any suggestion would be fine. I have installed DB2 Connect EE V8.1 (fixpak 4) at two different Windows 2000 Servers, both have the same regional settings. I am connecting to the same DB2...
4
by: G.Esmeijer | last post by:
Friends When I use a Querystring for insertdating data into a Tabel (going to SQLserver) the decimal pint changes to a comma. The result is that I get a system error (which I can understand) ...
3
by: DraguVaso | last post by:
Hi, I want to insert some recors in an Sql Server which have some decimal values: For exemple: I have a vairable called sngPi = 3,1415 (european notation: "," = comma) When I build my...
6
by: Tommy DN | last post by:
I think I've a simple question. I'm using the datatype "decimal". I need to build a sql - insert statement to save something in the database. But the problem is that the decimal - datatypes are...
4
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi everyone! I'm using greece - greek in my control panel's regional options, and so, my decimal point is the comma (,), while it is the dot (.) for the sql server db, however, I'm facing...
1
by: Twanne | last post by:
Hi, I've got some code in VBA where I calculate some numbers. Now some of them are large decimal numbers like -6,3216324E03. So in scientific notations. Now I need to add them to a table with an...
1
by: Joza | last post by:
Hi everybody! I have question about setting decimal symbols... In some countries, for example in my country we use comma for decimal symbol, but in in some other countries it is decimal point....
2
by: KiP.Kolodziejczyk | last post by:
I 'd like to insert (via "bulk insert") between 10-20 files (about 300MB each) into one table. The problem is that in input files decimal point is written as "," and without leading zeros (i.e.:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.