SqlDbType.Decimal ....how do you specify the decimal places?

Hi

I am trying to update my datasource with a decimal value. I know from my own deductive reasoning that the fault probable lies in the following code

With cmdUpdate.Parameters
                .Add("@VideoDetailID", SqlDbType.Int, 4, "VideoDetailID").SourceVersion = DataRowVersion.Original
                .Add("@VideoTitle ", SqlDbType.VarChar, 500, "VideoTitle")
                .Add("@VideoDuration", SqlDbType.Decimal, 9, "VideoDuration") '....................Specifically here!
                .Add("@VideoURL", SqlDbType.VarChar, 1000, "VideoURL")
                .Add("@GlobalAccessID", SqlDbType.Int, 4, "GlobalAccessID")
            End With

The problem I am having is that if I try and insert 2.45 what actually gets inserted is 2.00 so I need to know how to get round this problem.

I know the database datatype is set to decimal and it accepts decimals when inserted manually. My dataset also successfully holds the correct data but when I try and save the data, eg when I run the code above something happens and it does not insert the digits after the decimal place.

I have tried

.Add("@VideoDuration", SqlDbType.Decimal, 9,2, "VideoDuration")

But this does not work


Cheers


Paul G

pgilfeatherAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

samtran0331Commented:
>>The problem I am having is that if I try and insert 2.45 what actually gets inserted is 2.00 so I need to know how to get round this problem.

change the datatype of the table field to "float"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pgilfeatherAuthor Commented:
Thanks samtran0331,

but it is still not working. I tried inserting 2.45 and it just inserted 2.
samtran0331Commented:
Paul,

Did you change this line:
 .Add("@VideoDuration", SqlDbType.Decimal, 9, "VideoDuration")

to
 .Add("@VideoDuration", SqlDbType.Float, 8, "VideoDuration")

?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.