How to get rid of the exception "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine" in Win 7
I am running an ASP.NET C# application on .NET 4.0 framework using VS2010 on a Win 7 machine. Within my code I want to link Excel file with "DataTable" object. ie I want to access the data within Excel file and store it in DataTable object. So I used the following code snippet:
_
_connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"" + excelFile + "\";Extended Properties='Excel 8.0; HDR=NO; IMEX=1'";
}
DataTable table = new DataTable();
OleDbCommand command = new OleDbCommand();
command.Connection = new OleDbConnection(_connectionString);
command.CommandType = CommandType.Text;
command.CommandText = "select * from [NameOFExcelSheet$A1:D20]"; // Want to read the Excel sheet. The name of Excel sheet is "NameOfExcelSheet". Wan to read the celles in the range A1 and D20.
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = command;
adapter.Fill(table); // EXCEPTION OCCURS IN THIS LINE.
I installed the exe available at the link http://开发者_开发问答www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en
But still I am gettin the same exception msg while running my code. The exception that I am getting is "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine"
PLz help me with this.
THANKS IN ADVANCE.
You're probably on 64bit Windows and installed a 32bit driver. Either switch to 32bit compilation or source a 64bit driver.
You should try this (ensuring that you are in a x86 (32bits) machine ):
This download will install a set of components that can be used to facilitate transfer of data between 2007 Microsoft Office System files and non-Microsoft Office applications.
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en
精彩评论