用的OleDbConnection,Excel和连接池问题连接池、问题、OleDbConnection、Excel

2023-09-04 00:09:14 作者:感觉、快抓不住你了

所以,我在C#/ASP.NET OLEDB - MS Excel的阅读和QUOT;未指定的错误" 的,但我的my答案似乎并没有解决它。就连一直关闭的OleDbConnection和处置它表现出相同的症状。

So, I have the same symptoms as described in C#/ASP.NET Oledb - MS Excel read "Unspecified error", but my my answer did not seem to fix it. Even always closing the OleDBConnection and disposing of it show the same symptoms.

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();
    }
}

现在我已经发现了连接池以下信息:

Now I have found the following info on connection pooling:

.NET Framework数据提供程序的OLE DB自动使用OLE DB会话池池连接。连接字符串参数可用于启用或禁用OLE DB服务,包括池。例如,下面的连接字符串禁用OLE DB会话池和自动事务登记。

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.

供应商= SQLOLEDB; OLE DB服务= -4;数据源=本地主机;集成安全性= SSPI;

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服务,什么是 -4 的价值呢?

What is the connection string property OLE DB SERVICES and what is a value of -4?

推荐答案

如果我知道你想知道是什么意思的连接字符串属性纠正你的问题 OLE DB服务= -4

If I understand correct your question you want to know what means the connection string property OLE DB Services=-4.

您可以找到相应的文件这里,的这里和的此处。我希望的信息是你所需要的。如果你想与 DBPROPVAL_OS_AGR_AFTERSESSION 玩属性它的值是8(见oledb.h)。

You can find the corresponding documentation here, here and here. I hope the information is what you need. If you want play with DBPROPVAL_OS_AGR_AFTERSESSION property it has the value 8 (see oledb.h).