Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net Error in code to get the Access column type

Posted on 2013-01-16
4
Medium Priority
?
524 Views
Last Modified: 2013-01-16
Hi I am using the following code to get the Access column types for all tables.
It all works except for the line 'XXXXX
What should I use at this line to get the column type

    Sub Get_Access_Schema_Info()

        Try
            Dim oColumnName As String
            Dim oColumnType As String

            Dim cn As New OleDbConnection(Globals.ThisAddIn.oRIGHT.lblConnectionString.Text)
            cn.Open()

            'Retrieve the tables from the schema.
            Dim SchemaTable As DataTable = _
            cn.GetOleDbSchemaTable(schema:=Data.OleDb.OleDbSchemaGuid.Tables, _
            restrictions:=New Object() {Nothing, Nothing, Nothing, "Table"})

            Dim oIndex As Integer = -1

            For CountTables As Integer = 0 To SchemaTable.Rows.Count - 1

                oIndex = oIndex + 1
                'Get the table name.
                Dim TableName As String = SchemaTable.Rows(index:=CountTables)!TABLE_NAME.ToString()

                'Get the column names in the table.
                Dim SchemaColumn = cn.GetOleDbSchemaTable(schema:=OleDbSchemaGuid.Columns, _
                restrictions:=New Object() {Nothing, Nothing, TableName, Nothing})


                'Get each column name

                For CountColumns As Integer = 0 To SchemaColumn.Rows.Count - 1

                    oIndex = oIndex + 1

                    oColumnName = SchemaColumn.Rows(index:=CountColumns)!COLUMN_NAME.ToString
                    oColumnType = SchemaColumn.Rows(index:=CountColumns)!COLUMN_TYPE.ToString  'XXXXX

                Next

            Next CountTables

            cn.Close()

            cn.Dispose()

            cn = Nothing

        Catch ex As Exception
            MsgBox ex.Message)
        Finally
            'cn = Nothing
        End Try

    End Sub
0
Comment
Question by:Murray Brown
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38784418
What's the error?
0
 

Author Comment

by:Murray Brown
ID: 38784452
COLUMN_TYPE does not belong to table Columns
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38784511
0
 

Author Closing Comment

by:Murray Brown
ID: 38785873
Thanks very much
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question