简体   繁体   English

无法从SQL Server 2008连接到MS Access文件

[英]Cannot connect to MS Access file from SQL Server 2008

I have been trying for the past week or so to import data programmatically to a SQL Server 2008 table from a Microsoft Access .mdb file. 在过去一周左右的时间里,我一直在尝试从Microsoft Access .mdb文件中以编程方式将数据导入到SQL Server 2008表中。 I have been getting nothing but errors, and solving one just reveals another. 除了错误我什么都没有得到,解决一个错误就可以揭示另一个错误。 I made the file into a linked server, and now when I try to query it with: 我将文件制作为链接服务器,现在尝试使用以下命令进行查询:

Select * from OPENQUERY(Importdata, 'Select * from [IMBPieceBC]')

I get the error: 我收到错误:

OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "Importdata" returned message "Cannot open database ''.  It may not be a database that your application recognizes, or the file may be corrupt.".
Msg 7303, Level 16, State 1, Line 1
Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "Importdata".

I've read several suggestions to relink dlls in the registry, but I've done that, and I'm still getting the error. 我已经阅读了一些在注册表中重新链接dll的建议,但是我已经做到了,但是仍然出现错误。 Is there anything else I can do to fix it, or at least figure out what is wrong? 我还有什么办法可以修复它,或者至少可以找出出什么问题了?

Migrating the data to a SQL Server instance is not an option. 不能将数据迁移到SQL Server实例。 The mdb files are generated by a third-party program, so there's nothing we can do about it. mdb文件是由第三方程序生成的,因此我们无能为力。

I have a similar situation at my workplace - a third party application that maintains data in MDBs, but other applications needing access to it. 我的工作场所也遇到类似的情况-第三方应用程序在MDB中维护数据,但其他应用程序需要访问它。 How I've done it is that this 'intermediary' application has links to the SQL Server tables and the MDB tables. 我做的是,这个“中间”应用程序具有到SQL Server表和MDB表的链接。 You could use either a query or a VBA written form event to transfer information from the MDB table(s) involved into your corresponding SQL Server tables using a INSERT INTO query, fitted with a SELECT FROM subquery providing the values being inserted. 您可以使用INSERT INTO查询(带有SELECT FROM子查询,提供要插入的值)来使用查询或VBA书面形式事件将涉及的MDB表中的信息传输到相应的SQL Server表中。

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

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