问题
Can someone help me with this error? When I try to open a connection to an mdb, I get "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine" error. How can I correct this?
My code is pretty simple:
class ImportTDB {
private string filename;
private string connectionString;
private int collisions = 0;
public ImportTDB(String filename) {
this.filename = filename;
this.connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename;
}
public void loadCustomerList() {
DataTable dt = new DataTable();
using (OleDbConnection conn = new OleDbConnection(connectionString)) {
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Names", conn);
conn.Open();
adapter.Fill(dt);
conn.Close();
}
Console.WriteLine(dt.ToString());
}
}
回答1:
That's because there is no Jet driver for 64-bit systems and I suppose you are trying to run this on a x64 bit OS. You need to compile your program to target x86. In the project properties, Build tab, set Platform target to x86.
回答2:
If you are running your application in a 64 bit OS, Microsoft has now released the 2010 Office System Driver Beta: Data Connectivity Components which is supported both in 32 bit as well as 64 bit OS. So using this driver instead of the traditional Microsoft.Jet.OLEDB.4.0 driver will give us a 64 bit application running on a 64 bit server (that is what we really need).
Though this is in beta, it worked fine for me.
You can download this driver from 2010 Office System Driver Beta: Data Connectivity Components
Thnks
来源:https://stackoverflow.com/questions/1735392/the-microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine