2013-10-26 173 views
2

試圖Web服務器上創建的Access數據庫鏈接表時,得到錯誤的 - 錯誤是在ADOX.Catalog不知道我是否需要繼承ADOX還是怎麼樣?創建鏈接表在MS-Access數據庫的Web服務器

錯誤是:

編譯器錯誤消息: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 
+0

這裏是品嚐我使用的代碼的鏈接: http://msdn.microsoft.com/en-us/library/office/aa164914(v=office.10).aspx – BarclayVision

+0

聽起來像是你缺少一個參考或進口。可能是一個金塊埋葬在這裏:http://allenbrowne.com/func-adox.html(在最頂端它談論裁判)看起來好像是我的系統 – Plutonix

+0

是啊,一個COM對象,我看着那個,可以而她不知道該dll包括因爲我在做這個第三方服務器 – BarclayVision

回答

1

爲了使用ADOX你需要打開你的ASP.NET項目並添加以下COM參考:

Microsoft ADO Ext. 2.8 for DDL and Security

+0

我可以鏈接到另一個訪問數據庫表沒有ADOX.dll?例如:要獲取Access數據表架構,請通過ADO.NET使用OleDbConnection.GetOleDbSchemaTable方法。可以使用OLEDB更新鏈接的表數據而不是ADOX? – BarclayVision

+0

@BarclayVision你可能不需要。我會針對你的其他問題發表一個答案。 –

相關問題