Murray Brown
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(ByVa l 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=<st rong password>;Initial Catalog=Northwind"
Dim strConnection As String = "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=" & sDataBase
Dim cn As New OleDbConnection(strConnect ion)
Dim dt As DataTable
dt = cn.GetOleDbSchemaTable(Sys tem.Data.O leDb.OleDb SchemaGuid .Foreign_K eys, _
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
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(ByVa
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=<st
Dim strConnection As String = "Provider=Microsoft.Jet.OL
Dim cn As New OleDbConnection(strConnect
Dim dt As DataTable
dt = cn.GetOleDbSchemaTable(Sys
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER