Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Conversion of string to Decimal

Conversion of string to Decimal

Scheduled Pinned Locked Moved C#
databasehelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manowj
    wrote on last edited by
    #1

    Hi Everyone, Iam struck with sending a decimal parameter to a stored procedure. Can anyone help us in this regard cm.Parameters.Add("@test", SqlDbType.Decimal);

    Regards, Manowj

    D S P 3 Replies Last reply
    0
    • M manowj

      Hi Everyone, Iam struck with sending a decimal parameter to a stored procedure. Can anyone help us in this regard cm.Parameters.Add("@test", SqlDbType.Decimal);

      Regards, Manowj

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      What error are you getting?

      50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

      M 1 Reply Last reply
      0
      • M manowj

        Hi Everyone, Iam struck with sending a decimal parameter to a stored procedure. Can anyone help us in this regard cm.Parameters.Add("@test", SqlDbType.Decimal);

        Regards, Manowj

        S Offline
        S Offline
        Saksida Bojan
        wrote on last edited by
        #3

        Edit: It seems I was incorect with this statemnt.

        1 Reply Last reply
        0
        • M manowj

          Hi Everyone, Iam struck with sending a decimal parameter to a stored procedure. Can anyone help us in this regard cm.Parameters.Add("@test", SqlDbType.Decimal);

          Regards, Manowj

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          To parse a string that contains a numeric value, e.g. "123.45", to a Decimal, I recommend System.Decimal.TryParse[^].

          1 Reply Last reply
          0
          • D dan sh

            What error are you getting?

            50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

            M Offline
            M Offline
            manowj
            wrote on last edited by
            #5

            Hi, I am getting the below error when i passed cm.Parameters.Add("@Qty", SqlDbType.Decimal); Failed to convert parameter value from a String to a Decimal.

            Regards, Manowj

            D P 2 Replies Last reply
            0
            • M manowj

              Hi, I am getting the below error when i passed cm.Parameters.Add("@Qty", SqlDbType.Decimal); Failed to convert parameter value from a String to a Decimal.

              Regards, Manowj

              D Offline
              D Offline
              dan sh
              wrote on last edited by
              #6

              Check the value you are passing in @Qty. Are you passing a correct decimal value?

              50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

              1 Reply Last reply
              0
              • M manowj

                Hi, I am getting the below error when i passed cm.Parameters.Add("@Qty", SqlDbType.Decimal); Failed to convert parameter value from a String to a Decimal.

                Regards, Manowj

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                No string should be involved; how are you setting the Value of the parameter? I would use cm.Parameters.AddWithValue("@Qty", datetimepicker.Value ) Don't make a value into a string and then parse it back to the type is was.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups