Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net Get Access Columns and Data Types

Posted on 2013-01-16
2
Medium Priority
?
1,795 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:Murray Brown
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38784207
0
 

Author Closing Comment

by:Murray Brown
ID: 38784230
Thanks very much
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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.
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 …
Suggested Courses

972 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