size of a varchar field in SQLserver table

T

ton

Hi,

In ADO I could read the property .DefinedSize of a field of a recordset to
determine the max size of the field. This is very usefull to set the
maxlength property of a textbox. How can this value be determined in the
ADONET- Dataset or datatable.

thanks for a reply


Ton
 
W

William Vaughn

The same interfaces that VS uses to display these properties in the Server
Explorer are available via the GetSchema methods.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
T

ton

tell me how to do so. I only see a maxlength property of -1
cmd.CommandText = "select top 1 * from " & TableName
myReader = cmd.ExecuteReader(CommandBehavior.KeyInfo)
tbl = myReader.GetSchemaTable()

For Each col In tbl.Columns

' 'Display the field name and length
i = col.MaxLength
MsgBox(i & col.ColumnName )
 

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

Top