2012-06-20 88 views
1

,我发现了错误:OLEDB提供商没有找到

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

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

如何列出系统上可用的提供程序?

+0

这是使用Visual Studio的?如果是这样,您可以将目标CPU从64位更改为32. http://msdn.microsoft.com/en-us/library/ff407621.aspx – Thousand

+0

构建不使用VS,应用程序需要保留64位。 – Justin808

回答

4

How can my 64bit application access OLEDB?

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

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

How can I list the available providers on the system?

使用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("=================================="); 
    } 
} 
} 
相关问题