Field size in ADO.NET?

  • Thread starter Thread starter Wael Soliman
  • Start date Start date
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
 
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
 
Back
Top