Decimal value 0.00 becomes 0 in ASP.NET 1.1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sukanta Bhattacharjee
    New Member
    • Apr 2007
    • 4

    Decimal value 0.00 becomes 0 in ASP.NET 1.1

    Hi,
    I am in big trouble for the last 10 days and not got any solution in the web.
    My problem is : I have a project in .NET 1.1 version, which I have transfered to .NET 2.0 version , almost all are ok except one decimal value problem, it is like ...from my DataBase (Sql Server 2005) I am retreiving some records containg decimal value 0.00 , which is being stored into DataSet via SQL DataAdapter and when I am fetching that data (using DataSet object) 0.00 value becomes 0 in .NET 1.1 and in .NET 2.0 it remain same and I have done some logical calculation based on that value, which is not working properly in new .NET version due to this 0 problem.

    Please help me
  • channaJ
    New Member
    • Mar 2007
    • 67

    #2
    Originally posted by Sukanta Bhattacharjee
    Hi,
    I am in big trouble for the last 10 days and not got any solution in the web.
    My problem is : I have a project in .NET 1.1 version, which I have transfered to .NET 2.0 version , almost all are ok except one decimal value problem, it is like ...from my DataBase (Sql Server 2005) I am retreiving some records containg decimal value 0.00 , which is being stored into DataSet via SQL DataAdapter and when I am fetching that data (using DataSet object) 0.00 value becomes 0 in .NET 1.1 and in .NET 2.0 it remain same and I have done some logical calculation based on that value, which is not working properly in new .NET version due to this 0 problem.

    Please help me
    Hi Sukantha,

    As far as I understand, this can not be a problem. What ever the logical calculation you are performing can not be affected by this. If you can post the particular code segment, I might be able to help you.

    Comment

    • shweta123
      Recognized Expert Contributor
      • Nov 2006
      • 692

      #3
      Hi,

      Can you convert the value from Dataset using cdbl function ? So that it will get converted into double.

      Comment

      • Sukanta Bhattacharjee
        New Member
        • Apr 2007
        • 4

        #4
        Originally posted by channaJ
        Hi Sukantha,

        As far as I understand, this can not be a problem. What ever the logical calculation you are performing can not be affected by this. If you can post the particular code segment, I might be able to help you.
        Hi channaJ
        Thank you for your reply.
        Code in .NET 1.1
        decimal d1= Convert.ToDecim al(ds.Tables[0].Rows[0]["AEMSalBillOthe rCharges"]);
        "AEMSalBillOthe rCharges" is a decimal(18,2) type column in my table and the default value is set to 0.
        When I am checking (if(d1.ToString ()=="0")) is ok for .NET 1.1 version but same checking is not working in .NET 2.0 because d1.ToString() returns 0.00.
        I can change the code but for that I have to change more than 25 areas(web forms), which is a tested module and working properly.
        I m looking for such solution by that I dont need to change any code and can work in .NET 2.0 version.

        Comment

        • Sukanta Bhattacharjee
          New Member
          • Apr 2007
          • 4

          #5
          Re: Decimal value 0.00 becomes 0 in ASP.NET 1.1
          --------------------------------------------------------------------------------

          Quote:
          Originally Posted by channaJ
          Hi Sukantha,

          As far as I understand, this can not be a problem. What ever the logical calculation you are performing can not be affected by this. If you can post the particular code segment, I might be able to help you.


          Hi channaJ
          Thank you for your reply.
          Code in .NET 1.1
          decimal d1= Convert.ToDecim al(ds.Tables[0].Rows[0]["AEMSalBillOthe rCharges"]);
          "AEMSalBillOthe rCharges" is a decimal(18,2) type column in my table and the default value is set to 0.
          When I am checking (if(d1.ToString ()=="0")) is ok for .NET 1.1 version but same checking is not working in .NET 2.0 because d1.ToString() returns 0.00.
          I can change the code but for that I have to change more than 25 areas(web forms), which is a tested module and working properly.
          I m looking for such solution by that I dont need to change any code and can work in .NET 2.0 version.

          --------------------------------------------------------------------------------

          Comment

          • channaJ
            New Member
            • Mar 2007
            • 67

            #6
            Originally posted by Sukanta Bhattacharjee
            Re: Decimal value 0.00 becomes 0 in ASP.NET 1.1
            --------------------------------------------------------------------------------

            Quote:
            Originally Posted by channaJ
            Hi Sukantha,

            As far as I understand, this can not be a problem. What ever the logical calculation you are performing can not be affected by this. If you can post the particular code segment, I might be able to help you.


            Hi channaJ
            Thank you for your reply.
            Code in .NET 1.1
            decimal d1= Convert.ToDecim al(ds.Tables[0].Rows[0]["AEMSalBillOthe rCharges"]);
            "AEMSalBillOthe rCharges" is a decimal(18,2) type column in my table and the default value is set to 0.
            When I am checking (if(d1.ToString ()=="0")) is ok for .NET 1.1 version but same checking is not working in .NET 2.0 because d1.ToString() returns 0.00.
            I can change the code but for that I have to change more than 25 areas(web forms), which is a tested module and working properly.
            I m looking for such solution by that I dont need to change any code and can work in .NET 2.0 version.

            --------------------------------------------------------------------------------

            Hi Sukantha,

            Sorry for the late responce.(I didn't log in to the site during the weekend)

            What you have done here is not acceptable. Why are you converting the decimal to a string and compaire it as a string? THIS IS NOT A GOOD PRACTICE AT ALL.

            And the other thing is if d1 is a decimal it will definitely return the value 0.(not 0.00)

            What you can do here is use the condition
            Code:
            if(d1 == 0)
            instead of
            Code:
            (if(d1.ToString()=="0"))

            Comment

            • Sukanta Bhattacharjee
              New Member
              • Apr 2007
              • 4

              #7
              Originally posted by channaJ
              Hi Sukantha,

              Sorry for the late responce.(I didn't log in to the site during the weekend)

              What you have done here is not acceptable. Why are you converting the decimal to a string and compaire it as a string? THIS IS NOT A GOOD PRACTICE AT ALL.

              And the other thing is if d1 is a decimal it will definitely return the value 0.(not 0.00)

              What you can do here is use the condition
              Code:
              if(d1 == 0)
              instead of
              Code:
              (if(d1.ToString()=="0"))
              Hi channaJ,
              Yes d1 returns 0 in .NET 1.0 & 1.1 but in .NET 2.0 it returns 0.00.
              I have checked this issue and got the same result.

              Comment

              • channaJ
                New Member
                • Mar 2007
                • 67

                #8
                Originally posted by Sukanta Bhattacharjee
                Hi channaJ,
                Yes d1 returns 0 in .NET 1.0 & 1.1 but in .NET 2.0 it returns 0.00.
                I have checked this issue and got the same result.
                The problem with your code is that you are trying to compaire decimal values by converting them to strings. Just go through your code and eleminate this first.

                I'm also using .Net 2.0 and I my self checked this. You should be able to compaire it as a decimal.

                Comment

                Working...