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 &
")"
But: the result is offcourse: "INSERT INTO tblBlabla (MyName, Pi) VALUES
('Pieter', 3,1415)" which gives me an error that I want to insert 2 values,
and have only one field.
So I actually should insert it as ""INSERT INTO tblBlabla (MyName, Pi)
VALUES ('Pieter', 3.1415)" to work fine.
I could 'build' my variable as a string by taking the first part,
concattenating a point, and than concatenate the last part, but I guess
there must be a nicer and better way to work arround this problem. I want a
solution that works in every case, independent of the regional settings on
the application-pc and the sql-server.
Anybody any idea?
Thansk a lot in advance!
Pieter 3 7959
Use a data adapter or parameterized sql command object, it will take care of
the conversion for you.
"DraguVaso" <pi**********@h otmail.com> wrote in message
news:3f******** **************@ news.skynet.be. .. 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 & ")"
But: the result is offcourse: "INSERT INTO tblBlabla (MyName, Pi) VALUES ('Pieter', 3,1415)" which gives me an error that I want to insert 2
values, and have only one field.
So I actually should insert it as ""INSERT INTO tblBlabla (MyName, Pi) VALUES ('Pieter', 3.1415)" to work fine.
I could 'build' my variable as a string by taking the first part, concattenating a point, and than concatenate the last part, but I guess there must be a nicer and better way to work arround this problem. I want
a solution that works in every case, independent of the regional settings on the application-pc and the sql-server.
Anybody any idea?
Thansk a lot in advance!
Pieter
This may not be an ideal solution but here's one way you could do it:
sngPi.ToString. Replace(",", ".")
"DraguVaso" <pi**********@h otmail.com> wrote in message
news:3f******** **************@ news.skynet.be. .. 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 & ")"
But: the result is offcourse: "INSERT INTO tblBlabla (MyName, Pi) VALUES ('Pieter', 3,1415)" which gives me an error that I want to insert 2
values, and have only one field.
So I actually should insert it as ""INSERT INTO tblBlabla (MyName, Pi) VALUES ('Pieter', 3.1415)" to work fine.
I could 'build' my variable as a string by taking the first part, concattenating a point, and than concatenate the last part, but I guess there must be a nicer and better way to work arround this problem. I want
a solution that works in every case, independent of the regional settings on the application-pc and the sql-server.
Anybody any idea?
Thansk a lot in advance!
Pieter
"DraguVaso" <pi**********@h otmail.com> schrieb When I build my SQL-statement dynamically like: strSQL = "INSERT INTO tblBlabla (MyName, Pi) VALUES ('Pieter', " & sngPi & ")"
But: the result is offcourse: "INSERT INTO tblBlabla (MyName, Pi) VALUES ('Pieter', 3,1415)" which gives me an error that I want to insert 2 values, and have only one field.
So I actually should insert it as ""INSERT INTO tblBlabla (MyName, Pi) VALUES ('Pieter', 3.1415)" to work fine.
Use the Parameters property of the SQLCommand object.
--
Armin http://www.plig.net/nnq/nquote.html http://www.netmeister.org/news/learn2quote.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin |
last post by:
Hello,
I'm new with triggers and I can not find any good example on how to
do the following:
I have two tables WO and PM with the following fields:
WO.WONUM, VARCHAR(10)
WO.PMNUM, VARCHAR(10)
WO.PROBLEMCODE, VARCHAR(8)
|
by: Mike |
last post by:
I am getting a type mismatch error when I do a bulk insert.
---Begin Error Msg---
Server: Msg 4864, Level 16, State 1, Line 1
Bulk insert data conversion error (type mismatch) for row 1, column 14
(STDCOST).
---End Error Msg---
The STDCOST is set to decimal (28,14) and is a formatted in Access as a
number, single with 14 decimal. I don't know why I would be getting a Type
|
by: John D. |
last post by:
I am having problems inserting Decimal values into a DB2 database via
a .NET/C# application which is using an OdbcDataAdapter. Other field
types such as VarChar, Int, Date, etc work ok, and I can insert
literal values into a decimal field, but any attempt to insert a
decimal field via an OdbcParameter causes a
System.InvalidOperationException ("The connection is dead") to be
thrown by the DbDataAdapter.Update method.
The ODBC driver is...
|
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: ven |
last post by:
hello i`m makin a asp.net service with database connection where i have an
insert with decimal value, when i run my function i get this error :
There are fewer columns in the INSERT statement than values specified in the
VALUES clause. The number of values in the VALUES clause must match the
number of columns specified in the INSERT statement
this is my insert :
Dim queryString2 = "INSERT INTO
| |
by: Dot Net Daddy |
last post by:
Hello,
I cannot get the following Insert Command work. I get the error:
Error converting data type varchar to numeric.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
|
by: Noppers |
last post by:
I am trying to insert data into 2 tables, Order and Order_Item, in a transaction. Everything works fine if I only have 1 row in my objCartDT dataset. If I have only one row, the 2 tables are updated as expected. But if I have more than one row in the objCartDT, something fails, and I can't figure out what (but I suspect it has to do with the params in conjunction with "cmdNewOrder_Items.ExecuteNonQuery();" and the looping I'm trying to do. Maybe...
|
by: Santy |
last post by:
Hello All,
I am new to DB2,
Currently i am using DB2 version 8.02 personal edition on Windows XP
Professional.
And Facing problem with rowlock in insert query.
I have created a sample database as
CREATE TABLE SCEMANAME.LOG (
Sequence DECIMAL(9 ,0) NOT NULL ,
|
by: troydixon |
last post by:
Hello,
I am new at this, and have been trying to insert data into a table by using the footer of a gridview (which I dont like) or by using a detials view on the same page that is doing the following:
1) gets query string from url and filters records (works great) via a Details View
2) shows notes that have been added to the record shown in the details view using a grid view, and it filters the data by looking at the ID that is selected in...
|
by: maestroQC |
last post by:
Hi,
Its one of those days. I cannot solve this. Any help would be greatly
appreciated!
When I execute this:
class Db(object):
def insertAccount(self, date, accountNumber, description,
openingBalance):
dec = decimal.Decimal(openingBalance)
|
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...
| |
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.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |