2012-07-30 67 views
3

我有一個使用VBA在MS ACCESS 2007中編寫的應用程序,連接到後端的SQL Server。 Access和SQL Server都在本地運行。 我的機器運行Access 2010和MS SQL Server Express 2008 R2(都是32位,在WinXP上)沒有任何問題。使用SQL Server 2008運行Access 2010時的運行時錯誤'-2147024703(800700c1)'

我有另一臺機器,Win7 64位,同時運行Access 2010和SQL Server 2008(NOT R2)64位。

當我在64位機器上運行Access應用程序時,我有一個下拉框來選擇包含各種數據庫的SQL Server。當我選擇的服務器,幾秒鐘後,我得到一個錯誤:

Run-time error '-2147024703 (800700c1)':

Automation error %1 is not a valid Win32 application.

當我選擇調試選項,黃色箭頭指向: Set oServer = New SQLDMO.SQLServer

的下一行是: oServer.Connect ServerName, strSQLUser, strSQLPwd

在觀察列表中,我可以看到ServerNamestrSQLUser和strSQLPwd保存訪問SQL Server的正確值。我已經在sqlcmd中測試過這些,並且能夠成功查詢表。

任何人都可以請幫我一下嗎?我不確定接下來要做什麼。

回答

0

好像你已經在你的系統上註冊了一個32位SQLDMO,用於連接到64位實例。檢查您的註冊表/文件系統的SQLDMO.dll版本並註冊正確的一個。

同時檢查MSDN 「Installing SQL-DMO」 因爲是SQLDMO的SQL Server 2008 R2後,定於刪除:

Avoid using this feature in new development work, and plan to modify applications that currently use this feature.

SQL Server Database Management Objects (SQL-DMO) has been removed from SQL Server 2008 R2 Express and the SQL Server 2008 R2 Feature Pack. SQL-DMO also does not support Database Engine features introduced after SQL Server 2000. We recommend that you modify applications that currently use this feature as soon as possible. If you must support SQL-DMO, install the Backward Compatibility Components from the SQL Server 2008 Feature Pack from the Microsoft Download Center. Do not use SQL-DMO in new development work; use SQL Server Management Objects (SMO) instead. You can obtain the SMO documentation by installing SQL Server 2008 R2 Books Online.

0

感謝。

我期望找到SQLDMO.DLL 64位版本,但儘管使用向後兼容性軟件包用於x64,但使用MSI安裝並沒有完成這項工作。

我不得不手動提取文件並放置正確的版本(比x86版本大2MB,以表明知道哪一個是x64),然後在命令行中運行「regsvr32 sqldmo.dll」 (非常重要:需要以管理員身份運行cmd才能成功)。

模塊註冊後,我的Access前端運行良好。