• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 430
  • Last Modified:

Double vs MSSQL Decimal


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?


  • 3
  • 2
1 Solution
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.
Jerry_0001Author Commented:

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'
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.
It seems that the International issue in my 2nd comment was the solution.
Jerry_0001Author Commented:
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!!!!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now