Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > determine sql decimal precision in .net

Reply
Thread Tools

determine sql decimal precision in .net

 
 
Sam
Guest
Posts: n/a
 
      05-19-2006
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.
 
Reply With Quote
 
 
 
 
Tasos Vogiatzoglou
Guest
Posts: n/a
 
      05-19-2006
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

 
Reply With Quote
 
 
 
 
Sam
Guest
Posts: n/a
 
      05-22-2006
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Precision upto n decimal points Pp C Programming 10 12-05-2011 01:55 PM
TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why? Gilbert Fine Python 8 08-01-2007 01:58 AM
Decimal to Packed Decimal Conversion in C++ Ven C++ 3 08-01-2006 03:56 PM
Arbitrary precision decimal numbers =?ISO-8859-1?Q?Mattias_Br=E4ndstr=F6m?= C++ 5 04-26-2005 12:11 PM
Decimal precision ? Piotr ASP .Net 1 04-02-2004 12:43 PM



Advertisments
 



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