Results 1 to 3 of 3

Thread: [RESOLVED] How to insert values with decimal in database?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    Resolved [RESOLVED] How to insert values with decimal in database?

    Hi guys,

    I have a problem with my sql database. In my database, column Quantity has a data type of decimal. But why everytime I am trying to insert 1.25 in column quantity, and query it the result is 1. Where's 0.25?

    My code for asp.net is:

    Code:
    decimal qty = decimal.Parse(quantity);
    And for Stored Procedure:

    Code:
    @Quantity DECIMAL
    Do I have to use float instead of decimal?

    Thanks very much in advance

  2. #2
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: How to insert values with decimal in database?

    Taking a quick look (as its my lunch now), I think its because you've declared your parameter as DECIMAL and not DECIMAL(10,2) ... so its cutting off your decimal places.

    Try declaring the parameter in the stored proc as

    Code:
    @Quantity DECIMAL(10,2)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    Re: How to insert values with decimal in database?

    Thank you very much! It's working now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width