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

  • Question

  • User-774343849 posted

    Guys, I know this question has been here (and hundreds of other forums) before, but I can't get any of the proposed solutions I've found to work.

    The scenario is I try to read from an Excel-file, but I get the error The 'Microsoft.Jet. OLEDB.4.0' provider is not registered on the local machine. I'm on an Win XP, SP3, 32 bit, using VS2008 and ASP.NET 3.5, IIS 5.1 (my local machine, the test and prod servers will be win 2003 with IIS 6).

    I can find the Msjet40.dll in C:\Windows\System32 folder (and also in a folder called C:\Windows\ServicePackFiled\i386), and I've run regsvr32 on it (and also on Msjetoledb.dll, Mswstr10.dll, Msjter40.dll and Msjint40.dll according to this http://support.microsoft.com/kb/278604 - however the last three of these gave me the message DllRegisterServer entry point was not found. This file cannot be registered) And yes I have rebooted the machine after I did this.

     I've also tried to set Platform Target to x86 on the projects in my solution (even though this is a proposed solution for 64-bit computers). Well I guess that's it, anyone out there got more suggestions or ideas, anything might be helpful!

     My code



    string connectionString = @"Provider=Microsoft.Jet.
    OLEDB.4.0;Data Source=c:\tmp.xls;Extended
    Properties=""Excel 8.0;HDR=YES;"""

    DbProviderFactory factory =

    DbDataAdapter adapter = factory.CreateDataAdapter();

    DbCommand selectCommand = factory.CreateCommand();
    selectCommand.CommandText = "SELECT test1,test2,test3 FROM [thisIsATest$]";

    DbConnection connection = factory.CreateConnection();
    connection.ConnectionString = connectionString;

    selectCommand.Connection = connection;

    adapter.SelectCommand = selectCommand;

    DataSet cities = new DataSet();


     It fails on the adapter.Fill call.


    Thanks for any input! 

    Wednesday, September 17, 2008 3:47 AM


  • User-774343849 posted

     Moral of this story must be something like; be skeptic to code you find on the net (gods be damned - a day wasted).

    This code did the trick


                string strConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\tmp.xls;Extended Properties=""Excel 8.0;HDR=Yes;""";

    DataTable dt = new DataTable();

    using (OleDbConnection cnCSV = new OleDbConnection(strConnectionString))
    try { cnCSV.Open(); using (OleDbCommand cmdSelect = new OleDbCommand("SELECT test1,test3,test3 FROM [ThisIsATest$]", cnCSV))
    using (OleDbDataAdapter daCSV = new OleDbDataAdapter())
    daCSV.SelectCommand = cmdSelect;
    DataView view = dt.DefaultView;
    dt = view.ToTable();
    gridExcel.DataSource = dt;
    finally { cnCSV.Close(); } }
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 17, 2008 7:08 AM