1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Money in SQL

Discussion in 'SQL Server' started by CaJack, May 6, 2007.

  1. CaJack

    CaJack New Member

    Joined:
    Mar 21, 2007
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I'm having some trouble with my asp.net page and my sql database. What I'm trying to do is allow the user to upload an number to the database, the number is a money amount like 2.00 (£2.00) or 20.00(£20.00). I've tried using money and smallmoney datatypes but the numbers usually end up looking like this in the database...
    I enter 2.00 and in the database it looks like 2.00000, and even if I enter the information directly into the database I get the same results. I'm not going to be using big numbers with lots of decimal places like this 1000,000,0000. Can anyone help me? All I want is to know what to set the value to on my aspx page and what setting to set the field to in my database, I'd just like two pound to appear as 2.00. any help would be great.

    Thanks.
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Use string formatting,

    Code:
    'Create a var. named price that will be formatted as a currency
    Dim price as Double = 3.1
    Dim s as String 'create a string
    
    s = String.Format("{0:c}", price)
    
    Output:
    $3.10

    or perhaps something else, depending on your Web server's global locale information - that is, in China it may display a Yen symbol instead of the dollar sign
     
  3. clocking

    clocking New Member

    Joined:
    Jun 12, 2007
    Messages:
    122
    Likes Received:
    0
    Trophy Points:
    0
    hi !
    can you tell me about the connection asp.net to Sql server 2000. My connection has been failed.
    That is failure in user's name " sa ".
    So I had to chance Access.
    thanks so much.
    clocking.
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
  5. clocking

    clocking New Member

    Joined:
    Jun 12, 2007
    Messages:
    122
    Likes Received:
    0
    Trophy Points:
    0
    Thank you. I'll try it later when I have freetime.
    where are you doing now?
     

Share This Page