Windows Azure的远程站点“Microsoft.ACE.OLEDB.12.0'供应商未注册在本地计算机上 [英] Windows Azure remote site The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine

查看:182
本文介绍了Windows Azure的远程站点“Microsoft.ACE.OLEDB.12.0'供应商未注册在本地计算机上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下code正常工作我的本地开发机器上。但是我得到的,当我将它部署在 Azure的远程Web站点以下错误消息。我已经调查SO答案和谷歌的搜索结果,但它仍然不是很清楚,我什么我必须安装我的本地机器上,这样,当我推code天青,误差会自行消失。

错误消息:


  

在'Microsoft.ACE.OLEDB.12.0'供应商未注册在本地计算机上。


我的code ..

 字符串文件名=使用Server.Mappath(/)+MyExcelDataFile.xlsx
字符串的connectionString =的String.Format(供应商= Microsoft.ACE.OLEDB.12.0;数据源= {0};扩展属性= \\Excel中8.0; HDR = YES \\;,文件名);
查询字符串=的String.Format(SELECT * FROM [{0} $],myRange1);
OleDbDataAdapter的DataAdapter的=新OleDbDataAdapter的(查询的connectionString);
数据集的数据集=新的DataSet();
DataAdapter.Fill方法(数据集);
数据表YourTable = dataSet.Tables [0];


解决方案

如果您使用的是Azure的VM,只需安装从微软的网站的OLE DB驱动程序。

但是,如果您使用的是Web角色的Excel OLE驱动程序未对他们进行安装。

使用一个第三方组件,如 EPPlus 来查询您的Excel文件来代替。

The following code works correctly on my local dev machine. But I get the following error message when I deploy it on Azure remote web site. I have looked into SO answers and google search results but it still not clear to me what do I have to install on my local machine so that when I push the code to Azure, the error will go away.

Error Message:

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

My code..

string filename = Server.MapPath("/") + "MyExcelDataFile.xlsx";
string connectionString = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=YES\";", filename);
string query = String.Format("SELECT * from [{0}$]", "myRange1");
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
DataTable YourTable = dataSet.Tables[0];

解决方案

If you're using an Azure VM, just install the OLE DB driver from Microsoft's website.

But if you're using a Web Role Excel OLE Drivers aren't installed on them.

Use a 3rd party component such as EPPlus to query your Excel document instead.

这篇关于Windows Azure的远程站点“Microsoft.ACE.OLEDB.12.0'供应商未注册在本地计算机上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆