determine sql decimal precision in .net

S

Sam

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.
 
T

Tasos Vogiatzoglou

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
 
S

Sam

Tasos said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top