Field size in ADO.NET?

W

Wael Soliman

Hi all
In vb6 using ADO I can get the field size from recordset
for example: Size = Recordset.Fields(index).DefinedSize
How can I do it in vb.net using ADO.NET
Best regards
 
S

Sameh Refaat

Hi Wael
You can get information needed by using
table schema with the FillSchema method of the DataAdapter


Dim da As SqlClient.SqlDataAdapter
Dim ds As New DataSet
Dim con As SqlClient.SqlConnection

Try
Dim con As New SqlClient.SqlConnection("Your connection ")
Dim da As New SqlClient.SqlDataAdapter(TableName , con)
da.FillSchema(ds, SchemaType.Source, "Schema")

' Field Length = ds.Tables("schema").Columns(FieldName).MaxLength

Catch ex As System.Exception
MsgBox(ex.Message)
End Try

Best regards
Sameh Refaat
 

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