简体   繁体   English

SQL 访问链接服务器

[英]SQL to Access linked server

I am trying to add a linked server to a Access database.我正在尝试将链接服务器添加到 Access 数据库。 I am using the following SQL code to do this.我正在使用以下 SQL 代码来执行此操作。

exec sp_addlinkedserver 
@server = 'Test',
@provider = 'Microsoft.Jet.OLEDB.4.0',
@srvproduct = 'OLE DB Provider for Jet',
@datasrc = '\\srv\public$\CM Database\Data\sysConfig_dat.mdb'
go
EXEC sp_addlinkedsrvlogin Test, FALSE, Null, Admin, Null

but when i run this...但是当我运行这个...

select * from Test...tblProduct

i get this error...我收到这个错误...

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode. OLE DB 提供程序“Microsoft.Jet.OLEDB.4.0”不能用于分布式查询,因为提供程序配置为在单线程单元模式下运行。 what am i doing wrong?我究竟做错了什么?

I am using SQL Server Management Studio 2008 on a 32 bit system.我在 32 位系统上使用 SQL Server Management Studio 2008。

I figured it out...我想到了...

The server running SQL Server is a 64Bit machine.运行SQL Server的服务器是64Bit机器。 The typical data connectivity component drivers did not work with this machine (ie the download that installs the Microsoft.Jet.OleDB.4.0 as a provider).典型的数据连接组件驱动程序不适用于这台机器(即安装 Microsoft.Jet.OleDB.4.0 作为提供程序的下载)。 I had to download the components for Access 2010 which has a 64Bit option.我必须下载具有 64 位选项的 Access 2010 的组件。

Download from here 从这里下载

That installs the Microsoft.ACE.OLEDB.12.0 as a provider and I can use the SQL command that BradBenning mentioned in his post.这会将 Microsoft.ACE.OLEDB.12.0 安装为提供程序,我可以使用 BradBenning 在他的帖子中提到的 SQL 命令。

Try using the Microsoft ACE OLEDB provider:尝试使用 Microsoft ACE OLEDB 提供程序:

EXEC sp_addlinkedserver
   @server = 'Test'
  ,@provider = 'Microsoft.ACE.OLEDB.12.0'
  ,@datasrc = '\\srv\public$\CM Database\Data\sysConfig_dat.mdb'
  ,@srvproduct='Access'
GO 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM