By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

insert decimal value into MS SQL database

P: n/a
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_zamowienia]([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
Share this Question
Share on Google+
1 Reply


P: n/a
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_zamowienia]([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 discussion thread is closed

Replies have been disabled for this discussion.