Solved

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

Posted on 2013-01-16
4
498 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:murbro
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

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

Author Comment

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

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38784511
0
 

Author Closing Comment

by:murbro
ID: 38785873
Thanks very much
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now