2009-11-14 61 views
3

有人可以帮我解决这个错误吗?当我尝试打开一个到mdb的连接时,我得到“'Microsoft.Jet.OLEDB.4.0'提供程序未在本地计算机上注册”错误。我该如何解决这个问题?“Microsoft.Jet.OLEDB.4.0”提供程序未在本地计算机上注册

我的代码非常简单:

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()); 
    } 
} 
+0

我已经尝试此下载此驱动程序和它的工作般的魅力。 http://blog.nkadesign.com/2008/windows-2008-the-microsoftjetoledb40-provider-is-not-registered-on-the-local-machine/ –

回答

10

这是因为有no Jet driver for 64-bit systems,我想你想在x64位操作系统上运行此。你需要编译你的程序到x86。在项目属性“生成”选项卡中,将“平台目标”设置为x86。

+0

现在有一个[64位版本的Jet驱动程序]( http://stackoverflow.com/questions/1991643/microsoft-jet-oledb-4-0-provider-is-not-registered-on-the-local-machine/1992009#1992009)可用。但它也无法帮助,因为[其局限性](http://stackoverflow.com/questions/13854698/how-to-install-visual-studio-2010-setup-project-with-ms-access-database-在-A-COM#comment28064050_13854971)。 –

+0

相关:http://stackoverflow.com/a/1992009/1454514 –

5

如果您在64位操作系统中运行应用程序,Microsoft现在发布了支持32位和64位操作系统的2010 Office System Driver Beta:数据连接组件。因此,使用此驱动程序而不是传统的Microsoft.Jet.OLEDB.4.0驱动程序将为我们提供在64位服务器上运行的64位应用程序(这正是我们真正需要的)。

虽然这是在测试版,它对我来说工作得很好。

您可以从2010 Office System Driver Beta: Data Connectivity Components

Thnks

相关问题