determine sql decimal precision in .net

Discussion in 'ASP .Net' started by Sam, May 19, 2006.

  1. Sam

    Sam Guest

    Hi,

    I would like to be able to read the scale & precision of a decimal type
    contained in a sql server table from vb.net.
    I would like to set some properties (like width,format) of a gridview's
    field based upon the width (scale,precision) of the database column.

    Previously, in VB6 with ADO i was able to do that.
    In .Net i can read the dataType, but that returns me a .net decimal and
    apparently i cannot read a scale/precision from that.

    Any solutions or advise would be greatly appreciated.

    As a side question:
    we've tried to use our own types in sql server 2000. Apparently these
    are just aliasses for the underlying type (e.g.: someAmount =
    decimal(6,2)). We've tried reading these types in .Net, but also here we
    got a .Net decimal. If we could read our types (the names) then we could
    style the gridview's field accordingly.

    Sam.
    Sam, May 19, 2006
    #1
    1. Advertising

  2. You can use the GetSql<type> methods in the SqlDataReader.

    e.g.

    rdr.GetSqlDecimal(rdr.GetOrdinal("field"));

    SqlDecimal struct has the fields you want.

    Regards,
    Tasos
    Tasos Vogiatzoglou, May 19, 2006
    #2
    1. Advertising

  3. Sam

    Sam Guest

    Tasos Vogiatzoglou wrote:
    > You can use the GetSql<type> methods in the SqlDataReader.
    >
    > e.g.
    >
    > rdr.GetSqlDecimal(rdr.GetOrdinal("field"));
    >
    > SqlDecimal struct has the fields you want.
    >
    > Regards,
    > Tasos
    >


    Thanks Tasos, that was indeed the solution i was looking for.

    Sam.
    Sam, May 22, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piotr

    Decimal precision ?

    Piotr, Apr 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,562
    Martin Dechev
    Apr 2, 2004
  2. =?ISO-8859-1?Q?Mattias_Br=E4ndstr=F6m?=

    Arbitrary precision decimal numbers

    =?ISO-8859-1?Q?Mattias_Br=E4ndstr=F6m?=, Apr 21, 2005, in forum: C++
    Replies:
    5
    Views:
    512
    Alex Vinokur
    Apr 26, 2005
  3. Pp

    Precision upto n decimal points

    Pp, Dec 4, 2011, in forum: C Programming
    Replies:
    10
    Views:
    714
    gwowen
    Dec 5, 2011
  4. Replies:
    3
    Views:
    277
  5. Kay Y. Jheallee

    Setting longer default decimal precision

    Kay Y. Jheallee, Nov 18, 2013, in forum: Python
    Replies:
    7
    Views:
    98
    Tim Golden
    Nov 20, 2013
Loading...

Share This Page