在Web服务器上的MS-Access DB中创建链接表

时间:2013-10-26 17:41:56

标签: asp.net vb.net ms-access-2003

尝试在Web服务器上的访问数据库中创建链接表时出错 - ADOX.Catalog上的错误是不确定我是否需要继承ADOX或如何?

错误是:

  

编译器错误消息:BC30002:未定义类型“ADODB.Catalog”。

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

1 个答案:

答案 0 :(得分:1)

要使用ADOX,您需要打开ASP.NET项目并添加以下COM引用:

Microsoft ADO Ext. 2.8 for DDL and Security