473,748 Members | 8,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

insert decimal value into MS SQL database

ven
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
[pozycja_zamowie nia]([id_artykulu],[id_zamowienia],[cena_netto],[cena_brutto],[zamowiono],[trybrejestracji],[typ],[kod_vat],[jednostka])
values" & _
"('" & id_artykulu & "','" & numer & "'," & cena_netto & "," & cena_brutto &
"," & ilosc & ",'" & tryb & "','" & typ & "','" & kod_vat & "','" &
jednostka & "')"

where ilosc is my decimal value, everythings works when i have '" & ilosc &
"' and ilosc was a string value, but the database field is a decimal field
and i change ilosc from string to decimal and it wont work now

Nov 19 '05 #1
1 7657
When you say it "does not work" can you please be a bit more descriptive.
Something cannot work in a billion ways and yet each billion way could have
a differnet error or do something differently.

Is it throwing an Exception? Is it throwing az compiler time terror?
If it is throwing a compiler time eror make sure you are calling
ilosc.ToString( )
If you are getting an Exception then check to see what queryString2 is
before you insert it.
for example you may have to format it using a ToString overload because it
might be doing something like
3.200000E-7 and this might not be sql compatbile.

If the above does not solve your problem then please provide more
descriptive details about the error or results you are experiencing.

"ven" <ve*****@poczta .onet.pl> wrote in message
news:ct******** *@news.onet.pl. ..
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
[pozycja_zamowie nia]([id_artykulu],[id_zamowienia],[cena_netto],[cena_brutto],[zamowiono],[trybrejestracji],[typ],[kod_vat],[jednostka])
values" & _
"('" & id_artykulu & "','" & numer & "'," & cena_netto & "," & cena_brutto
& "," & ilosc & ",'" & tryb & "','" & typ & "','" & kod_vat & "','" &
jednostka & "')"

where ilosc is my decimal value, everythings works when i have '" & ilosc
& "' and ilosc was a string value, but the database field is a decimal
field and i change ilosc from string to decimal and it wont work now

Nov 19 '05 #2

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

Similar topics

3
1404
by: Brian Conway | last post by:
Can anyone give me a quick little break down of what I would need to do to insert information into a database onClick of and Submit button? I am new to all of this and have done it with datagrids, but want to do it with just textboxes filled in and on click of the Submit button that it would take those boxes and insert a record into the database. This is for C#. below is a little of what I have on the submit button but I don't think it...
9
3460
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)
0
2274
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...
3
6514
by: Brenny | last post by:
Hello I'm developing a project by using access database and there is a table(Table1) and it has a field(ml_mik) this is the decimal field. I'm taking a value from windows form as a decimal variable(for example 12,3 or 12.3). After saving record, value(12,3 or 12.3) is saved as 123, not 12,3 or 12.3... I'm using ADO.NET for processes in the database.
2
1615
by: ven | last post by:
Hello i have two tables in my MS SQL named table1 and table2. In each table i have a column PRICE with my own datatype decimal 14;4 allows nulls.... now i wanna select from one table to second table and i can do it here is my code : select * from table1 dim variable = datareader("PRICE")
11
2256
by: Pieter | last post by:
Hi, I'm having some troubles with my numeric-types in my VB.NET 2005 application, together with a SQL Server 2000. - I first used Single in my application, and Decimal in my database. But a Single with value 4.475 was converted to a Decimal with value 4.4749999999999996D. So after inserting and selecting it from the database I got another value than the original!
8
9410
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 ,
0
4062
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...
2
7340
by: ksenthilbabu | last post by:
Hey All, I am using MSSQL -2005 with VB6. I have created a master table tblCompany and detail Table tblDetail having foreign key relationship. When i try to insert a value within a TRANSACTION I am getting Error No. -2147217873 at Line No. 0 (The INSERT statement conflicted with the FOREIGN KEY constraint "FK_tblDetail_tblCompany". The conflict occurred in database "DBTest", table "dbo.tblCompany", column RefID.) . please help me to solve...
0
8991
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, 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...
0
8830
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9541
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, 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...
0
9370
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 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...
0
9247
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 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...
0
6074
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();...
0
4602
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...
1
3312
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
3
2215
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.