Home All Groups Group Topic Archive Search About

How to get a column size in VB.net

Author
27 Nov 2007 1:04 PM
Vanny
How could I get a column size from a datareader or a datatable?  We're
moving from VB6 where the code looks like this:  rcs.Fields(i).Size (rcs is
a recordset).

Thank for your help

Vanny

Author
27 Nov 2007 6:45 PM
Cor Ligthert[MVP]
Vanny,

With a datareader only with a lot of trouble.

With a datatable .

http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.maxlength(VS.71).aspx

Be aware that this is of course only for a string value

Cor
Author
27 Nov 2007 8:29 PM
Vanny
Thank you for the response.  I tried this code : dt.Columns(i).MaxLength
where dt is a datatable.  It always gives the value -1.  It does not return
the field sizes for the varchar fields of the table.
Thanks,

Vanny

Show quote
"Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message
news:FFF031CF-F3DA-4798-A902-5E61B354E9C4@microsoft.com...

> Vanny,
>
> With a datareader only with a lot of trouble.
>
> With a datatable .
>
> http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.maxlength(VS.71).aspx
>
> Be aware that this is of course only for a string value
>
> Cor

AddThis Social Bookmark Button