insert decimal value into MS SQL database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ven

    insert decimal value into MS SQL database

    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



  • Guest's Avatar

    #2
    Re: insert decimal value into MS SQL database

    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" <venome_@poczta .onet.pl> wrote in message
    news:cticij$u9$ 1@news.onet.pl. ..[color=blue]
    > 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
    >
    >
    >[/color]


    Comment

    Working...