Solved

VB.net Get Access Columns and Data Types

Posted on 2013-01-16
2
1,548 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
Comment Utility
0
 

Author Closing Comment

by:murbro
Comment Utility
Thanks very much
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

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…
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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.

772 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

10 Experts available now in Live!

Get 1:1 Help Now