How to get field's DefinedSize from ADO.NET?

I know to get field size from a table by ado is as below:

Set Recordset = Server.CreateObject("ADODB.Recordset")
Recordset.Open "SELECT * FROM TABLE", connection
Size = Recordset.Fields("Field1").DefinedSize

But how to do the same for
Please give a code example. Thanks
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

lengreenConnect With a Mentor Commented:
Hi limct,

'SQL Server Connection

Dim strSQL as string = "SELECT FirstName,LastName FROM Employees;"
Dim strConnection as String = "server=;database=Northwind; User Id=sa;password=;"

Dim objDataSet As New DataSet()
Dim objConnection As New SqlConnection(strConnection)

'create a new DataAdapter using the connection object and select statement
Dim objDataAdapter As New SqlDataAdapter(strSQL, objConnection)

'fill the dataset with data from the DataAdapter object
objDataAdapter.Fill(objDataSet, "Employees")

Dim Size as integer

Size = objDataSet.Tables("Employees").Columns("FirstName").Maxlength

All Courses

From novice to tech pro — start learning today.