Double vs MSSQL Decimal

Posted on 2006-05-14
Last Modified: 2008-03-06

I seem to have a problem when inserting and updating data in an MSSQL database.

I have declared 3 variables:
Dim var1 as double
dim var2 as double

In the database there is a table named Table1 that has 3 coulumns
TID  --> Integer (Primary Key)
C1 --> Decimal (Precision 2)
C2 --> Decimal (Precision 2)

Now when I try to insert or update those 2 doubles to the database I receive an error.
It seems that .NET updates a double like 11,24
MSSQL on his side only seems to accept the format 11.24

Can you help me with this?


Question by:Jerry_0001
    LVL 22

    Expert Comment

    Double is not the same as Decimal.

    Technically, Decimal data type is an Integer with implied decimal positions, whereas Double is a Floating Point number.

    I'm not sure why you're getting the command, but I would suggest changing one or the other of your data types so they match.

    Author Comment


    Well this project exsits out of 2 phases.
    Phase 1 was a survey, that people could fill in.
    Phase 2 (now) is the calculation of the results.

    Calculate the percentages of each awnser. Problem is that it has to be stored in the database with a precision of 2.
    I have to put these results on a website but also in a word doc. Here I can't format the data anwymore.

    But I already tried both ways. It doesn't work with decimal nor float.

    I always receive this:
    "UPDATE resAnon SET a11A = 93,75 and a11B= 6,25 WHERE RID=1"
    and I get an error like " Line 1: Incorrect syntax near '75'
    LVL 22

    Accepted Solution

    It appears that you international setting are configured for European (or one variation), and apparently it wants "American" with periods rather than commas as your decimal symbol.

    Try looking in Control Panel under international settings.
    LVL 22

    Expert Comment

    It seems that the International issue in my 2nd comment was the solution.

    Author Comment

    I'm sorry. Due to some circumstances I haven't been able to go on on this question.

    The only way I got further is to do everything with parameters.

    MyCommand.Parameters.Add(New SQLParameter("@var1", SQLDataType.VarChar, 11))
    MyCommand.Parameters("@var1").Value = var1

    That way everything worked...

    Thanks for the help!!!!


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now