没有找到OLEDB提供商

时间:2012-06-20 20:59:52

标签: c# oledb

我收到了错误:

System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

我有一个64位系统,64位应用程序安装了Office 2010 32位。我的64位应用程序如何访问OLEDB?

如何在系统中列出可用的提供商?

1 个答案:

答案 0 :(得分:4)

  

我的64位应用程序如何访问OLEDB?

“Microsoft.ACE.OLEDB.12.0”,即Microsoft Access数据库引擎2010可再发行组件可以从here下载。还有一个64位版本。

可以找到“Microsoft.ACE.OLEDB.12.0”提供程序的连接字符串here

  

如何在系统中列出可用的提供商?

使用OleDbEnumerator.GetRootEnumerator

using System;
using System.Data;
using System.Data.OleDb;

class Program
{
 static void Main()
 {
   OleDbDataReader reader = OleDbEnumerator.GetRootEnumerator();

   DisplayData(reader);

   Console.WriteLine("Press any key to continue.");
   Console.ReadKey();
 }

 static void DisplayData(OleDbDataReader reader)
 {
   while (reader.Read())
   {
     for (int i = 0; i < reader.FieldCount; i++)
     {
       Console.WriteLine("{0} = {1}",
        reader.GetName(i), reader.GetValue(i));
     }
     Console.WriteLine("==================================");
   }
 }
}