Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.net Get Access Columns and Data Types

Hi

How do I change the following codes to get all the table names, columns and column data types and then display the results in a DataGridView

    Function GetTableRelationships(ByVal sDataBase As String)
        Try
            'Connect to the Northwind database in SQL Server.
            'Be sure to use an account that has permission to list tables.
            'cn.ConnectionString = "Provider=SQLOLEDB;Data Source=server;User ID=<username>;Password=<strong password>;Initial Catalog=Northwind"

            Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDataBase
            Dim cn As New OleDbConnection(strConnection)


            Dim dt As DataTable

            dt = cn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Foreign_Keys, _
            New Object() {Nothing, Nothing, Nothing, "TABLE"})

            DataGridView1.DataSource = dt
        Catch
            frmR.TopMost = False
            Me.TopMost = False
            MsgBox("There was an error! " & Err.Description & ".")
            frmR.TopMost = True
            Me.TopMost = True
        End Try


    End Function
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Murray Brown

ASKER

Thanks very much