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 8199
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.co m> 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.Sql DbType.NVarChar ,
length);
param1.Value = aValue;
insCmd.Paramete rs.Add(param1);
SqlParameter param1 = new SqlParameter("@ B", System.Data.Sql DbType.Int);
param1.Value = bValue;
insCmd.Paramete rs.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.t iscali.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******** ******@TK2MSFTN GP11.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.Sql DbType.NVarChar , length); param1.Value = aValue; insCmd.Paramete rs.Add(param1); SqlParameter param1 = new SqlParameter("@ B", System.Data.Sql DbType.Int); param1.Value = bValue; insCmd.Paramete rs.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.t iscali.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 decimal separator of
the decimal columns has become a comma while it was a dot.
Example resultset :
Before Fixpack 5:
|
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 z/OS subsystem running V7 from a DB2 Command
Window, and I do a "select decimal-field from table" - but at machine-a I
get the field with comma as...
|
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)
sSQL = "INSERT A,B INTO TABEL VALUES (aValue, BValue");
where A ="aaa"
and B = 12.5
|
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 SQL-statement dynamically like:
strSQL = "INSERT INTO tblBlabla (MyName, Pi) VALUES ('Pieter', " & sngPi &
|
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 written with a comma " , " and not " . ".
So when I make the string:
--
dim decimalvariable as decimal
sql = "insert into table(decimalthing)...
| |
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 trouble when I need to parse the sql server decimal as
an asp.net double!
For example:
|
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 insert query.
The query:
db.Execute ("INSERT INTO tmpZscore (datum, leeftijd, lengte, ZscoreL, gewicht, ZscoreW, BMI, ZscoreB, IBW) VALUES('" &...
|
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. The problem is when
I use comma and want to save data in database.
For example if i want to save number 4,50 it saves like 450, but
if i write 4.50...
|
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.: ",45"), and sever uses ".".
So I 've got an "type mismatch" error.
I can't re-build input file, as well as I can't change configuration
of mssql...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |