Programmatically Determin Max Field Length

  • Thread starter Thread starter crjunk
  • Start date Start date
C

crjunk

I'm trying to programmatically determine the maximum field length for
an Access table. I've had problems using the examples that I have come
across on the internet. Can anyone provide me with a simple way to
determine the max length of a field?

Thanks,
CR Junk
 
crjunk said:
I'm trying to programmatically determine the maximum field length for
an Access table. I've had problems using the examples that I have come
across on the internet. Can anyone provide me with a simple way to
determine the max length of a field?

Thanks,
CR Junk

I was able to obtain the maximum field lenght by using the following
code:

Dim tmpML as String
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM
MyInfo WHERE 1 = 0", objConn)
Dim daMaxLength As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim myDataSet As DataSet
myDataSet = New DataSet
daMaxLength.Fill(myDataSet, "MyInfo")
daMaxLength.FillSchema(myDataSet, SchemaType.Source, "MyInfo")

tmpML =
myDataSet.Tables("MyInfo").Columns("FirstName").MaxLength.ToString


CR Junk
 
Back
Top