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 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
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
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
> 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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)
...
|
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...
|
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...
|
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...
|
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...
|
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....
|
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.:...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |