Home » excel » c# – Unrecognized database format

c# – Unrecognized database format

Posted by: admin April 23, 2020 Leave a comment


I would like to ask, why I get this exception when I try to connect excel 2000/3 and also 2010?

using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;

namespace md1_connect
    class Program

        static void Main (string[] args)
            string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"Book1.xls\"";            
            OleDbConnection MyConn = new OleDbConnection(ConnectionString);
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM[Sheet2$]", MyConn);
            OleDbDataReader dataReader = cmd.ExecuteReader();

            while (dataReader.Read())
How to&Answers:

You need to tell the provider you’re using Excel 97-2003 (xls as opposed to xlsx) by appending:

Extended Properties="Excel 8.0"


string ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"Book1.xls\";Extended Properties=\"Excel 8.0\"";


I dont know what the exception is but I may know what you are talking about. You are probably compiling as x64 bit, please force it to run as 32 bit (x86). I believe that setting can be set in your Project Properties under Build Options