Size of datacolumn

F

F. A.B.

Hi,

The datatype property of a datacolumn tells me about its type, but how can i
have the size of a datacolumn.

Thanks for your help.
 
W

William \(Bill\) Vaughn

If you're asking about the length of a VarChar, it can be retrieved from the
Columns collection assuming you ask for it nicely. Make sure to include
MissingSchemaAction.AddWithKey to fill this in.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
cn = New SqlConnection("Data Source=demoserver;integrated
security=sspi;initial catalog=biblio")
da = New SqlDataAdapter("select au_id,author from authors", cn)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds)
Debug.WriteLine(ds.Tables(0).Columns(1).MaxLength())
End Sub


hth

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
F

F. A.B.

Thank you for your help.

William (Bill) Vaughn said:
If you're asking about the length of a VarChar, it can be retrieved from the
Columns collection assuming you ask for it nicely. Make sure to include
MissingSchemaAction.AddWithKey to fill this in.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
cn = New SqlConnection("Data Source=demoserver;integrated
security=sspi;initial catalog=biblio")
da = New SqlDataAdapter("select au_id,author from authors", cn)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds)
Debug.WriteLine(ds.Tables(0).Columns(1).MaxLength())
End Sub


hth

--
____________________________________
Bill Vaughn
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

can
 

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