Solved

VB.net Get Access Columns and Data Types

Posted on 2013-01-16
2
1,623 Views
Last Modified: 2013-01-16
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
0
Comment
Question by:murbro
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 38784207
0
 

Author Closing Comment

by:murbro
ID: 38784230
Thanks very much
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

770 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