3

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];
dotnet-practitioner
  • 13,968
  • 36
  • 127
  • 200
  • Install this component on destination server - http://www.microsoft.com/en-us/download/details.aspx?id=13255 – ramiramilu Jan 16 '14 at 13:23

2 Answers2

3

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.

Cam Bruce
  • 5,632
  • 19
  • 34
2

I think this is because the OleDb driver does not exist on the virtual machine of azure but does exist on your local development machine.

If you are using Windows Azure Virtual Machine, you can find the installation of Microsoft.ACE.OLEDB.12.0 driver, copy and install through RDP on your azure machine then it should be solved.

If you are using Windows Azure Cloud Service, then you might need to find an approach to install/register this driver (COM I guess) through the Startup/Task process. And you also need to make sure the the driver supports x64.

If you are using Windows Azure Website, that might be a problem since I don't think you can install/register additional component regardless which Website Plan (Free, Shared to Standard) you are using.

Hope this helps.

Shaun Xu
  • 4,476
  • 2
  • 27
  • 41