SQL to Access linked server

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 07:21:32

问题


I am trying to add a linked server to a Access database. I am using the following SQL code to do this.

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. what am i doing wrong?

I am using SQL Server Management Studio 2008 on a 32 bit system.


回答1:


I figured it out...

The server running SQL Server is a 64Bit machine. 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). I had to download the components for Access 2010 which has a 64Bit option.

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.




回答2:


Try using the Microsoft ACE OLEDB provider:

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


来源:https://stackoverflow.com/questions/5873673/sql-to-access-linked-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!