View Full Version : Decimal datatype not working


jal
01-27-2009, 11:45 PM
I can't seem to get the Decimal datatype to work. I thought it would store sevaral digits after the decimal point. In my testing, I am trying to insert the following value:

.123456789

But in datasheet view it just shows a value of zero after the insert. I know the insert is successful, because the other fields did just fine. This is the code I'm using (this is a native Access table)

Sql = "INSERT INTO testTable....."
Call cmd.Parameters.Append(cmd.CreateParameter("@Num", adDecimal))
cmd.Parameters("@Num").Value = .12345789
cmd.Execute

If I change the value to an integer it works fine, like this:

cmd.Parameters("@Num").Value = 2500

but the problem is that I need to insert decimal numbers. In design view, the datatype for this column is "Decimal" and the "Precision" is 18. So why isn't the engine preserving up to 18 digits past the decimal point?

I am using ADOB and I tried setting the param length but that didn't help either.

Ron_dK
01-28-2009, 12:04 AM
Try changing your (number) field to :

Field size : double
format : general number
decimal places : auto

Hth

jal
01-28-2009, 12:11 AM
Ok, I think I got it, I think Access requires me to set the Scale in design view.

jal
01-28-2009, 12:14 AM
Try changing your (number) field to :

Field size : double
format : general number
decimal places : auto

Hth Yes, thanks, that would probably have solved it as well.