On Thu, 6 Jan 2005 16:19:01 -0800, "Job Lot" <Jo****@discuss ions.microsoft. com> wrote:
Is there any way to programmaticall y link access tables using vb.net
Yes, you can use ADOX (Microsoft ADO Ext 2.x for DDL and Security) via interop. The below example
links to a table in an Access database:
Sub CreateAttachedA ccessTableWithA DOX()
Dim ADOXTable As New ADOX.Table
Dim ADOXCatalog As New ADOX.Catalog
Dim ADOConnection As New ADODB.Connectio n
Try
ADOConnection.O pen("Provider=M icrosoft.Jet.OL EDB.4.0;" & _
"Data Source=e:\My Documents\db1.m db;" & _
"Jet OLEDB:Engine Type=4;")
ADOXCatalog.Act iveConnection = ADOConnection
ADOXTable.Name = "Table11Lin ked"
ADOXTable.Paren tCatalog = ADOXCatalog
ADOXTable.Prope rties("Jet OLEDB:Link Provider String").Value = "MS Access;DATABASE =E:\My
Documents\Acces sDB.mdb"
ADOXTable.Prope rties("Jet OLEDB:Remote Table Name").Value = "Table11"
ADOXTable.Prope rties("Jet OLEDB:Create Link").Value = True
ADOXCatalog.Tab les.Append(ADOX Table)
Catch ex As Exception
MessageBox.Show (ex.Message)
Finally
ADOConnection.C lose()
End Try
End Sub
Paul ~~~
pc******@amerit ech.net
Microsoft MVP (Visual Basic)