Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-16
4
Medium Priority
?
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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