错误:'Microsoft.ACE.OLEDB.12.0'提供程序不支持ITransactionLocal接口。有任何先决条件吗?

5

通过不同的API,我使用相同的参数到达相同的代码。

public void Foo(string nprPath, int maxConnections = 3)
{
    var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + nprPath;

    using (var connectionPool = new ConnectionPool(maxConnections, connectionString))
    {
       ....
    }
}

我输入了准确的参数进入方法。其中一个API成功执行,而另一个则抛出以下异常:

{"The ITransactionLocal interface is not supported by the 'Microsoft.ACE.OLEDB.12.0' 
provider.Local transactions are unavailable with the current provider."}

使用ACE.OLEDB.12需要什么先决条件?

1个回答

8
您可以尝试在连接字符串中添加";OLE DB Services=-4"
类似于以下内容:
var connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;OLE DB Services=-4;Data Source=" + nprPath;

请查看这个相关的论坛

编辑:-

当 "OLE DB Services = -4;" 时,它的含义是:

除了连接池和自动事务登记之外的所有内容

请参考MSDN了解更多信息。


2
非常好。问题解决了。我想应该节省了我几个小时的时间。你有什么想法为什么会不同吗? - Bick
@rails:我更新了我的回答。希望能有所帮助! :) - Rahul Tripathi

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接