How do I get the scale and precision of a Decimal column? RRS feed

  • Question

  • I cannot seem to find a way to tell the precision and scale of a decimal column. There were properties in the ADO column object that told you this, but nothing like that in ADO.NET.

    After much time spent on google the only clue was to somehow use GetDataTableSchema. But having to learn an entirely new technology (Xml Schemas and the tools to navigate them) just to do something that use to take two lines of simple code is hardly fair.

    Is there an easy way to do this?


    Wednesday, August 13, 2008 9:01 PM

All replies

  • There is probably a better .Net way to do this. However, The scale and precision are stored in the system views of your SQL Server database.




    You could wrap this into a method pretty easily.


    I'm looking forward to seeing another post with a better method.





    Wednesday, August 20, 2008 6:15 PM
  • Benji,

    Querying the schema from SQL server system tables is a really good tool I use from time to time. It's the quickest way to determine if a field exists for instance.

    However, in this case I am connecting to an MDB via ADO.NET. Thinking along similar lines to your suggestion I did a cursory looksy for any DDL way to query the schema, but have some more digging to do. Any ideas youself?

    For this particular function I have regressed, for time being, to using ADO But it just seems wrong to use ADO and ADO.NET in the same EXE.

    I also use MySQL, so any agnostic solution would be the best.


    Wednesday, August 20, 2008 11:31 PM