In order to use ADOX you need to open your ASP.NET project and add the following COM reference:
Microsoft ADO Ext. 2.8 for DDL and Security
Question
getting error when trying to create linked table in access DB on web server - error is on the ADOX.Catalog
not sure if I need to inherit ADOX or how?
error is:
Compiler Error Message: BC30002: Type 'ADODB.Catalog' is not defined.
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load
''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim A As String = "e:\web\Training.mdb"
Dim B As String = "e:\web\LeaveDB.mdb"
Dim C As String = "UsersDataTbl"
Dim D As String = "NewUsers"
CreateLinkedAccessTable(A,B,C,D)
End Sub
Sub CreateLinkedAccessTable(strDBLinkFrom As String, strDBLinkTo As String, strLinkTbl As String, strLinkTblAs As String)
Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
Set catDB = New ADOX.Catalog
' Open a Catalog on the database in which to create the link.
catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDBLinkFrom
Set tblLink = New ADOX.Table
With tblLink
' Name the new Table and set its ParentCatalog property to the
' open Catalog to allow access to the Properties collection.
.Name = strLinkTblAs
Set .ParentCatalog = catDB
' Set the properties to create the link.
.Properties("Jet OLEDB:Create Link") = True
.Properties("Jet OLEDB:Link Datasource") = strDBLinkTo
.Properties("Jet OLEDB:Remote Table Name") = strLinkTbl
End With
' Append the table to the Tables collection.
catDB.Tables.Append tblLink
Set catDB = Nothing
End Sub
Solution
In order to use ADOX you need to open your ASP.NET project and add the following COM reference:
Microsoft ADO Ext. 2.8 for DDL and Security