0

我正在尝试从 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 语句以保持数据库最新,直到我们在转换过程中进一步替换它。为了使这些查询成功运行,我需要进行哪些更改?

4

2 回答 2

0

试试这个,请注意用户Admin,区分大小写

Select FName
From 
OpenRowSet('Microsoft.ACE.OLEDB.12.0',
'\\bespin\Files\GDrive\CPros\Databases\Client.mdb';
'Admin';'',
Residents)
于 2014-04-25T06:02:34.973 回答
-1

Your specified path is wrong.

It should be as following example for an Excel sheet:

select *  from OPENROWSET(        
  'Microsoft.ACE.OLEDB.12.0','Excel 8.0;Database=D:\Band.Xlsx',        
  'SELECT * FROM [SheetName$]');
于 2013-08-02T10:40:58.390 回答