G
George
All,
I am trying to get some schema information about columns in my MS
Access table. I attempt to use the GetSchemaTable method as
illustrated below:
Dim lobj_Connection As OleDbConnection
Dim lobj_DataReader As OleDbDataReader
Dim lobj_Command As OleDbCommand
Dim lobj_DataTable As DataTable
Dim lobj_Row As DataRow
Dim lobj_Column As DataColumn
Try
'Get the field information
lobj_Connection = New OleDbConnection
lobj_Connection.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""d:\Documents and
Settings\gmcgd\My Documents\Softball\League2003.mdb"";"
lobj_Connection.Open()
lobj_Command = New OleDbCommand
lobj_Command.Connection = lobj_Connection
lobj_Command.CommandText = "Select * From League_Info"
lobj_DataReader =
lobj_Command.ExecuteReader(CommandBehavior.KeyInfo)
'Create the datatable
lobj_DataTable = lobj_DataReader.GetSchemaTable()
For Each lobj_Row In lobj_DataTable.Rows
For Each lobj_Column In lobj_DataTable.Columns
la_Fields(li_IX) = lobj_Column.ColumnName
la_FieldTypes(li_IX) = lobj_Column.GetType
la_FieldLengths(li_IX) = lobj_Column.MaxLength
Next
Next
--------------------------------------
Every time I run this the value of lobj_Column.ColumnName is
'ColumnName' and not the name of the column from my table. Any ideas
what I am doing wrong?
Thanks
George
I am trying to get some schema information about columns in my MS
Access table. I attempt to use the GetSchemaTable method as
illustrated below:
Dim lobj_Connection As OleDbConnection
Dim lobj_DataReader As OleDbDataReader
Dim lobj_Command As OleDbCommand
Dim lobj_DataTable As DataTable
Dim lobj_Row As DataRow
Dim lobj_Column As DataColumn
Try
'Get the field information
lobj_Connection = New OleDbConnection
lobj_Connection.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""d:\Documents and
Settings\gmcgd\My Documents\Softball\League2003.mdb"";"
lobj_Connection.Open()
lobj_Command = New OleDbCommand
lobj_Command.Connection = lobj_Connection
lobj_Command.CommandText = "Select * From League_Info"
lobj_DataReader =
lobj_Command.ExecuteReader(CommandBehavior.KeyInfo)
'Create the datatable
lobj_DataTable = lobj_DataReader.GetSchemaTable()
For Each lobj_Row In lobj_DataTable.Rows
For Each lobj_Column In lobj_DataTable.Columns
la_Fields(li_IX) = lobj_Column.ColumnName
la_FieldTypes(li_IX) = lobj_Column.GetType
la_FieldLengths(li_IX) = lobj_Column.MaxLength
Next
Next
--------------------------------------
Every time I run this the value of lobj_Column.ColumnName is
'ColumnName' and not the name of the column from my table. Any ideas
what I am doing wrong?
Thanks
George