insert decimal value into MS SQL database

V

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top