decimal vs. int vs. numeric ???

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default decimal vs. int vs. numeric ???

    First, I apologize if this is posted in the wrong area ... it has to do with
    mySQL and ASP ...

    I had two fields in a mySQL table:
    cost
    quantity

    Both were of the type Int. I needed decimal places for the Cost field so
    changed both to be Numeric (also tried this with the type being decimal)
    cost - numeric 6,2
    quantity - numeric 11,0

    Before when they were both Int I had an asp page :
    vTot = cost * quantity
    This was working fine, but didn't take decimals.

    When I changed the data type to decimal/numeric I'm getting a Type Mismatch.

    Any idea on why this is happening and how to fix it?

    Thanks!!!


    Robin Guest

  2. Similar Questions and Discussions

    1. decimal validation
      how can i use javascript to ensure a the user enters a decimal number up to a certain place holder? what would that code look like? Chris O'Brien
    2. Double or Decimal?
      I need a variable to store values from -0.5 to 5.0 Should I use a decimal or a double for this as it looks like I can user either. Any help on...
    3. Converting to decimal
      I've imported some data from a mainframe db via text file. The file contains this: credit_hours pic 9(2)v9 (COBOL, it basically says 3 number...
    4. Converting from decimal to hex
      Hi. I have an array consisting of mac addresses in decimal form seperated by : Like this: 0:0:33:195:37:6 0:0:180:75:15:17 and so on I now...
    5. converting HH:MM to a decimal
      I have 3 pairs of time in/out (24 our clock) that I need to calculate the decimal equivalent of the total time worked for that day. example: ...
  3. #2

    Default Re: decimal vs. int vs. numeric ???

    > When I changed the data type to decimal/numeric I'm getting a Type
    Mismatch.

    Can you show the code that causes this error?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]


    Aaron Bertrand - MVP Guest

  4. #3

    Default Re: decimal vs. int vs. numeric ???

    <%vTot = rsList("Quantity") * rsList("Cost")%>



    "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    news:OWwreESOEHA.624@TK2MSFTNGP11.phx.gbl...
    > > When I changed the data type to decimal/numeric I'm getting a Type
    > Mismatch.
    >
    > Can you show the code that causes this error?
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > [url]http://www.aspfaq.com/[/url]
    >
    >

    Robin Guest

  5. #4

    Default Re: decimal vs. int vs. numeric ???

    Is it possible that one or both are null?

    Try

    <%
    q = CInt(rsList("Quantity"))
    c = CDbl(rsList("Cost"))
    vTot = CDbl(q * c)
    %>

    Quantity should be INT, by the way, not NUMERIC. Unless you can buy half of
    something, you will never need the decimal places.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Robin" <rlaxton@energymasterllc.com> wrote in message
    news:56Qoc.12282$5z5.757@bignews2.bellsouth.net...
    > <%vTot = rsList("Quantity") * rsList("Cost")%>
    >
    >
    >
    > "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    > news:OWwreESOEHA.624@TK2MSFTNGP11.phx.gbl...
    > > > When I changed the data type to decimal/numeric I'm getting a Type
    > > Mismatch.
    > >
    > > Can you show the code that causes this error?
    > >
    > > --
    > > Aaron Bertrand
    > > SQL Server MVP
    > > [url]http://www.aspfaq.com/[/url]
    > >
    > >
    >
    >

    Aaron Bertrand - MVP Guest

  6. #5

    Default Re: decimal vs. int vs. numeric ???

    Genious ... that worked. What exactly is that code doing??

    "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    news:OVb5VVSOEHA.1620@TK2MSFTNGP12.phx.gbl...
    > Is it possible that one or both are null?
    >
    > Try
    >
    > <%
    > q = CInt(rsList("Quantity"))
    > c = CDbl(rsList("Cost"))
    > vTot = CDbl(q * c)
    > %>
    >
    > Quantity should be INT, by the way, not NUMERIC. Unless you can buy half
    of
    > something, you will never need the decimal places.
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > [url]http://www.aspfaq.com/[/url]
    >
    >
    >
    >
    > "Robin" <rlaxton@energymasterllc.com> wrote in message
    > news:56Qoc.12282$5z5.757@bignews2.bellsouth.net...
    > > <%vTot = rsList("Quantity") * rsList("Cost")%>
    > >
    > >
    > >
    > > "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    > > news:OWwreESOEHA.624@TK2MSFTNGP11.phx.gbl...
    > > > > When I changed the data type to decimal/numeric I'm getting a Type
    > > > Mismatch.
    > > >
    > > > Can you show the code that causes this error?
    > > >
    > > > --
    > > > Aaron Bertrand
    > > > SQL Server MVP
    > > > [url]http://www.aspfaq.com/[/url]
    > > >
    > > >
    > >
    > >
    >
    >

    Robin Guest

  7. #6

    Default Re: decimal vs. int vs. numeric ???

    Converting quantity to an Integer, and converting cost to a Double. You can
    find these and other conversion methods in the VBScript documentation.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Robin" <rlaxton@energymasterllc.com> wrote in message
    news:UyQoc.29301$su1.623@bignews3.bellsouth.net...
    > Genious ... that worked. What exactly is that code doing??

    Aaron Bertrand - MVP Guest

  8. #7

    Default Re: decimal vs. int vs. numeric ???

    Hi Aaron

    Where is this VB script documentation?

    I use wordpad/notepad and IIS/PWS to create ASP pages and I've not been able
    to source this kind of documentation in a readable format anyway.

    Rgds

    Robbie

    "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
    news:O0YGMdSOEHA.3596@tk2msftngp13.phx.gbl...
    Converting quantity to an Integer, and converting cost to a Double. You can
    find these and other conversion methods in the VBScript documentation.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Robin" <rlaxton@energymasterllc.com> wrote in message
    news:UyQoc.29301$su1.623@bignews3.bellsouth.net...
    > Genious ... that worked. What exactly is that code doing??


    Astra Guest

  9. #8

    Default Re: decimal vs. int vs. numeric ???

    Documentation for every MS product can be found at
    msdn.microsoft.com/library where you can read it online. For the vbscript
    documentation, expand the Web Development node in the table of contents
    (toc). Then the Scripting node, then the Documentation node, then Windows
    Script Technology node, and lastly the VBScript node, where you will see
    both a User's Guide and the Reference.

    Additionally, you can download the Scripting documentation from :
    [url]http://tinyurl.com/7rk6[/url]

    HTH,
    Bob Barrows

    Astra wrote:
    > Hi Aaron
    >
    > Where is this VB script documentation?
    >
    > I use wordpad/notepad and IIS/PWS to create ASP pages and I've not
    > been able to source this kind of documentation in a readable format
    > anyway.
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  10. #9

    Default Re: decimal vs. int vs. numeric ???

    Many thanks Bob



    Bob Barrows [MVP] <reb01501@NOyahoo.SPAMcom> wrote in message
    news:uDhiFvaOEHA.2740@TK2MSFTNGP11.phx.gbl...
    Documentation for every MS product can be found at
    msdn.microsoft.com/library where you can read it online. For the vbscript
    documentation, expand the Web Development node in the table of contents
    (toc). Then the Scripting node, then the Documentation node, then Windows
    Script Technology node, and lastly the VBScript node, where you will see
    both a User's Guide and the Reference.

    Additionally, you can download the Scripting documentation from :
    [url]http://tinyurl.com/7rk6[/url]

    HTH,
    Bob Barrows

    Astra wrote:
    > Hi Aaron
    >
    > Where is this VB script documentation?
    >
    > I use wordpad/notepad and IIS/PWS to create ASP pages and I've not
    > been able to source this kind of documentation in a readable format
    > anyway.
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"




    Laphan Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139