【问题标题】:Using OpenRowSet to connect to an Access 2000 Database from SQL Server Management Studio使用 OpenRowSet 从 SQL Server Management Studio 连接到 Access 2000 数据库
【发布时间】:2013-06-27 20:40:08
【问题描述】:

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

【问题讨论】:

    标签: sql-server-2008 oledb openrowset ms-access-2000


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      您指定的路径错误。

      Excel 工作表应如下例所示:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-11-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-14
        • 1970-01-01
        • 2019-12-27
        相关资源
        最近更新 更多