The ‘Microsoft.ACE.OLEDB.12.0′ provider is not registered on the local machine (zz)

//z 2012-08-13 17:53:02 IS2120@csdn.T1380725028[T91,L1441,R37,V860]
Well I wanted to set up what I thought would be a simple Excel file import into my ProxyChecker, so I used previous code to upload the file to the web server and create a OLEDB connection to it.

My Excel 8  (Excel 2003) connection string was:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
 + ServerFullPath
 + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\""); 

And my Excel 12 (Excel 2007) connection string was;

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
 + ServerFullPath
 + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; 

But when I went to run, both XLS and XLSX connections would fail with either:

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.

or

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

//z 2012-08-13 17:53:02 IS2120@csdn.T1380725028[T91,L1441,R37,V860]
I sourced the problem to the fact that the connection strings I was trying to use 32-bit drivers, but I was on a 64-bit Sharepoint installation. After a bit of research I found that it doesn’t appear there were ever any 64-bit Office 2007 drivers, but luckily there are some for 2010, and they appeared to be backward compatible.

So after downloading them from here I went to install them only to be faced with an error saying they couldn’t be installed because I had pre-installed 32-bit office applications. Luckily it told me what they were (as I would have not remembered) – you may have guessed – it was Sharepoint Designer 2007.

After the uninstall the AccessDatabaseEngine_X64.exe installation went with out a hitch. So I change my XLSX connection string to Microsoft.ACE.OLEDB.12.0 and BOOM – new error;

The 'Microsoft.ACE.OLEDB.14.0' provider is not registered on the local machine.

Best laid plans of mice and men….

I checked the driver version in ODBC and yep – definitely version 14. Then by complete luck I can across a mention that the version number hadnt been changed in the connection string (sounds like an omission to me) – so I put it back to Microsoft.ACE.OLEDB.12.0 – and ZOOM – everything works.

So there you go. If you are trying to create a connection to an XLSX (Excel 2007) spreadsheet, ensure you have no 32-bit Office apps on the server, install AccessDatabaseEngine_X64.exe  and set your connection string to;

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
 + ServerFullPath
 + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";

The good news is that this driver also works for XLS (Excel 2003) by simply changing the Excel version reference;

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
 + ServerFullPath
 + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\"";
//z 2012-08-13 17:53:02 IS2120@csdn.T1380725028[T91,L1441,R37,V860]
`Provider=Microsoft.ACE.OLEDB.12.0` 是用于连接到 Microsoft Access 数据库的连接字符串的一部分。要获取这个字符串,你需要确保你的计算机上安装了适当的驱动程序,并且你的应用程序或开发环境支持使用该驱动程序。 如果你正在使用 Microsoft Access 数据库,你可以按照以下步骤来获取 `Provider=Microsoft.ACE.OLEDB.12.0`: 1. 确保你的计算机上安装了 Microsoft Access Database Engine。你可以从 Microsoft 官方网站下载并安装它。 2. 在你的应用程序中,创建一个连接到 Access 数据库的连接字符串。连接字符串通常包含数据库文件的路径、访问权限和其他参数。下面是一个示例连接字符串: ```csharp string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\path\\to\\your\\database.accdb;Persist Security Info=False;"; ``` 在这个示例中,`Provider=Microsoft.ACE.OLEDB.12.0` 指定了使用的 OLE DB 提供程序,`Data Source` 指定了数据库文件的路径,`Persist Security Info=False` 表示不持久化安全信息。 3. 使用连接字符串创建数据库连接对象,然后执行相应的操作,如查询数据、插入记录等。 请注意,上述示例中的连接字符串仅适用于连接到单个 Access 数据库文件。如果你需要连接到一个网络位置上的 Access 数据库或者使用其他版本的 Access 数据库引擎,你可能需要调整连接字符串中的参数。 希望这可以帮助到你!如果你有其他关于连接字符串的问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值