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. Database & SysAdmin
  3. Database
  4. smallmoney

smallmoney

Scheduled Pinned Locked Moved Database
question
4 Posts 3 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.
  • P Offline
    P Offline
    pickron
    wrote on last edited by
    #1

    How can I get rid of the value of 3000.0000 since its datatype is money ? I would like it to be 3000, not 3000.0000. The code is: Dim pMoney As SqlParameter = New SqlParameter("@Money", SqlDbType.Money, 8) pMoney.Value = Trim(CInt(txtMoney.Text)) cmdUpdate.Parameters.Add(pMoney) Did I overlook something ? Thanks!

    R L 2 Replies Last reply
    0
    • P pickron

      How can I get rid of the value of 3000.0000 since its datatype is money ? I would like it to be 3000, not 3000.0000. The code is: Dim pMoney As SqlParameter = New SqlParameter("@Money", SqlDbType.Money, 8) pMoney.Value = Trim(CInt(txtMoney.Text)) cmdUpdate.Parameters.Add(pMoney) Did I overlook something ? Thanks!

      R Offline
      R Offline
      Rob Graham
      wrote on last edited by
      #2

      The problem is not in how you are storing it (Actually your expectations are the only problem). 3000 in smallmoney is accurate to four decimal places, so it == 3000.0000 when stored. How are you viewing the result? Unless you apply formatting to the display/print, the default would be to display it at full precision. Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed. Carl Sandburg

      P 1 Reply Last reply
      0
      • R Rob Graham

        The problem is not in how you are storing it (Actually your expectations are the only problem). 3000 in smallmoney is accurate to four decimal places, so it == 3000.0000 when stored. How are you viewing the result? Unless you apply formatting to the display/print, the default would be to display it at full precision. Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed. Carl Sandburg

        P Offline
        P Offline
        pickron
        wrote on last edited by
        #3

        Rob, Hee hee, my expectation is just simple and easy. 4 decimal places isn't what I want it in my project but I can't change the precision in the Design Table of the SQL Ext. Manager. I did try CInt(txtMoney.text) but it won't get rid of the 4 decimal places. (i.e. from 4500.0000 to 4500) Thanks for replying.

        1 Reply Last reply
        0
        • P pickron

          How can I get rid of the value of 3000.0000 since its datatype is money ? I would like it to be 3000, not 3000.0000. The code is: Dim pMoney As SqlParameter = New SqlParameter("@Money", SqlDbType.Money, 8) pMoney.Value = Trim(CInt(txtMoney.Text)) cmdUpdate.Parameters.Add(pMoney) Did I overlook something ? Thanks!

          L Offline
          L Offline
          Luis Alonso Ramos
          wrote on last edited by
          #4

          In C# I cast it to a decimal and then to a double and then convert it to a string, and it only outputs the decimals that are not 0 (10.5 instead of 10.5000). Something like:

           string s = ((double) (decimal) row["MoneyAmount"]).ToString();
          

          In VB.NET you could try something similar and it might work. -- LuisR


          Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

          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