不支持 ITransactionLocal 接口

发布于 2024-07-09 23:34:51 字数 686 浏览 7 评论 0原文

我有一个 .NET 3.5 C# 库,它使用 OleDb 从 Excel 文件中提取数据并将其返回到 DataRowCollection 中,该数据由 SQL Server 2005 中的 CLR 表值函数使用。

当我在其上使用 SELECT 时,该函数工作正常。 但是,如果我想使用其输出作为 INSERT INTO 表的源,则会收到以下错误:

System.InvalidOperationException:“Microsoft.Jet.OLEDB.4.0”提供程序不支持 ITransactionLocal 接口。 当前提供商无法进行本地交易。 系统.InvalidOperationException: 在System.Data.OleDb.OleDbConnectionInternal.EnlistTransactionInternal(事务事务,布尔强制自动) 在 System.Data.OleDb.OleDbConnection.Open() 在 GetExcelFunction.GetFile(String strFileName) 在 GetExcelFunction.InitMethod(String strFileName)

那么,我该如何解决这个问题? 我是否要阻止连接创建事务? 如果是这样怎么办? 我在 OleDbConnection 上没有看到任何相关方法或属性。 连接字符串中有参数吗?

I have a .NET 3.5 C# library that uses OleDb to pull data from an Excel file and return it in a DataRowCollection which is used by a CLR Table-Valued Function in SQL Server 2005.

The function works fine when I use SELECT on it. But if I want to use its output as a source for an INSERT INTO a table, I get the following error:

System.InvalidOperationException: The ITransactionLocal interface is not supported by the 'Microsoft.Jet.OLEDB.4.0' provider. Local transactions are unavailable with the current provider.
System.InvalidOperationException:
at System.Data.OleDb.OleDbConnectionInternal.EnlistTransactionInternal(Transaction transaction, Boolean forcedAutomatic)
at System.Data.OleDb.OleDbConnection.Open()
at GetExcelFunction.GetFile(String strFileName)
at GetExcelFunction.InitMethod(String strFileName)

So, how do I solve this? Do I stop the connection from creating the transaction? If so how? I don't see any relevant methods or properties on the OleDbConnection. Is there a parameter in the connection string?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是一片海 2024-07-16 23:34:51

将“;OLE DB Services=-4”添加到连接字符串。

add ";OLE DB Services=-4" to connection string.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文