2013-06-27 172 views
0

我試圖從SQL Server Management Studio連接到Access 2000數據庫。我當前的查詢是:使用OpenRowSet從SQL Server Management Studio連接到Access 2000數據庫

sp_configure 'show advanced options', 1; 
RECONFIGURE; 
GO 
sp_configure 'Ad Hoc Distributed Queries', 1; 
RECONFIGURE; 
GO 

Select FName 
From 
OpenRowSet('Microsoft.ACE.OLEDB.12.0', 
'\\bespin\Files\GDrive\CPros\Databases\Client.mdb'; 
'admin';'', 
Residents) 

起初,我試圖用Microsoft.Jet.OLEDB.4.0作爲供應商。由於這兩臺服務器實際上都是在64位操作系統上運行,所以我不得不切換到Microsoft.ACE.OLEDB.12.0。

運行該查詢返回以下錯誤:

OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "The Microsoft Access database engine cannot open or write to the file '\\bespin\Files\GDrive\CPros\Databases\Client.mdb'. It is already opened exclusively by another user, or you need permission to view and write its data.". 
Msg 7303, Level 16, State 1, Line 2 
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)". 

我已經檢查,沒有其他人有打開數據庫。如果我嘗試改變的東西的用戶名和密碼的數據庫的管理權限,將返回下面的錯誤,而不是:

OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" returned message "Not a valid account name or password.". 
Msg 7399, Level 16, State 1, Line 2 
The OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)" reported an error. Authentication failed. 
Msg 7303, Level 16, State 1, Line 2 
Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "(null)". 

最後,我需要發生的是要能夠運行一系列的INSERT/UPDATE語句使數據庫保持最新狀態,直到我們在轉換過程中進一步替換它爲止。爲了使這些查詢成功運行,需要更改哪些內容?

回答

0

您指定的路徑是錯誤的。

它應該是如下的一個Excel工作表例如:

select * from OPENROWSET(  
    'Microsoft.ACE.OLEDB.12.0','Excel 8.0;Database=D:\Band.Xlsx',   
    'SELECT * FROM [SheetName$]'); 
0

試試這個,請注意用戶聯繫的,它是區分大小寫

Select FName 
From 
OpenRowSet('Microsoft.ACE.OLEDB.12.0', 
'\\bespin\Files\GDrive\CPros\Databases\Client.mdb'; 
'Admin';'', 
Residents) 
相關問題