gpt4 book ai didi

.net - OleDbConnection、Excel 和连接池的问题

转载 作者:行者123 更新时间:2023-12-03 02:14:17 25 4
gpt4 key购买 nike

所以,我有与C#/ASP.NET Oledb - MS Excel read "Unspecified error"中描述的相同的症状,但是我的my answer似乎没有修复它。即使总是关闭 OleDBConnection 并处理它也会显示相同的症状。

var connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Extended Properties=Excel 12.0;", _excelFile);
using (var conn = new OleDbConnection(connectionString))
{
try
{
DoSomething();
}
finally
{
conn.Close();
}
}

现在我找到了以下有关连接池的信息:

The .NET Framework Data Provider for OLE DB automatically pools connections using OLE DB session pooling. Connection string arguments can be used to enable or disable OLE DB services including pooling. For example, the following connection string disables OLE DB session pooling and automatic transaction enlistment.

Provider=SQLOLEDB;OLE DB Services=-4;Data Source=localhost;Integrated Security=SSPI;

We recommend that you always close or dispose of a connection when you are finished using it in order to return the connection to the pool. Connections that are not explicitly closed may not get returned to the pool. For example, a connection that has gone out of scope but that has not been explicitly closed will only be returned to the connection pool if the maximum pool size has been reached and the connection is still valid.

(来源:http://msdn.microsoft.com/en-us/library/ms254502.aspx)

连接字符串属性 OLE DB SERVICES 是什么?-4 的值是什么?

最佳答案

如果我理解正确您的问题,您想知道连接字符串属性 OLE DB Services=-4 的含义。

可以找到对应的文档here , herehere 。我希望这些信息是您所需要的。如果您想使用 DBPROPVAL_OS_AGR_AFTERSESSION 属性,则其值为 8(请参阅 oledb.h)。

关于.net - OleDbConnection、Excel 和连接池的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6174724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com