连接池在.Net SQL Server 2008中不起作用

时间:2021-08-29 15:55:39

I'm testing out my application with the hopes of migrating to SQL Server 2008 (From 200). In the SQL Server profiler, I'm seeing

我正在测试我的应用程序,希望迁移到SQL Server 2008(从200开始)。在SQL Server探查器中,我看到了

    Audit Login
    SQL:BatchStarting             SELECT .....
    SQL:BatchCompleted            SELECT .....
    Audit Logout

for every single query that is being run. From what I can tell, this means that it's creating a new connection for every single query I run, and not using connection pooling. Is this the case? If it is, is there anything I can do to trouble shoot why connection pooling wouldn't be working. I'm using a single constant strings for connection strings, and I'm always closing (to release it back to the pool) the connection immediately after I'm done with it. My connection string doesn't have pooling disabled, and there is a minimum pool size of 10, with a maximum pool size of 1000.

对于正在运行的每个查询。据我所知,这意味着它为我运行的每个查询创建一个新连接,而不是使用连接池。是这样的吗?如果是,有什么我可以做的麻烦拍摄为什么连接池不起作用。我正在为连接字符串使用单个常量字符串,并且在完成连接之后,我总是关闭(将其释放回池中)连接。我的连接字符串没有禁用池,并且最小池大小为10,最大池大小为1000。

Has anybody else experienced similar problems? Just in case it matters, it's an ASP.NET application (VB.NET) running on XP Professional (my development box). I've compiled my web app targetting the .NET 2 framework.

还有其他人遇到过类似的问题吗?万一它很重要,它是一个在XP Professional(我的开发盒)上运行的ASP.NET应用程序(VB.NET)。我已经编译了我的Web应用程序,目标是.NET 2框架。

2 个解决方案

#1


This is expected behavior. From the documentation for the Audit Login Event Class:

这是预期的行为。从审核登录事件类的文档:

The Audit Login event class indicates that a user has successfully logged in to Microsoft SQL Server. Events in this class are fired by new connections or by connections that are reused from a connection pool.

Audit Login事件类指示用户已成功登录到Microsoft SQL Server。此类中的事件由新连接或从连接池重用的连接触发。

You should look at the appropriate connection performance counters to see how many connections you really have (on the client and server).

您应该查看相应的连接性能计数器,以查看您实际拥有的连接数(在客户端和服务器上)。

#2


To answer your question, No. This behavior does not mean that your connections are not being pooled. As casper explained, you will see these events even when pooled connections are reused.

要回答您的问题,请注意,否。此行为并不意味着您的连接未被合并。正如casper所解释的那样,即使重用池化连接,您也会看到这些事件。

#1


This is expected behavior. From the documentation for the Audit Login Event Class:

这是预期的行为。从审核登录事件类的文档:

The Audit Login event class indicates that a user has successfully logged in to Microsoft SQL Server. Events in this class are fired by new connections or by connections that are reused from a connection pool.

Audit Login事件类指示用户已成功登录到Microsoft SQL Server。此类中的事件由新连接或从连接池重用的连接触发。

You should look at the appropriate connection performance counters to see how many connections you really have (on the client and server).

您应该查看相应的连接性能计数器,以查看您实际拥有的连接数(在客户端和服务器上)。

#2


To answer your question, No. This behavior does not mean that your connections are not being pooled. As casper explained, you will see these events even when pooled connections are reused.

要回答您的问题,请注意,否。此行为并不意味着您的连接未被合并。正如casper所解释的那样,即使重用池化连接,您也会看到这些事件。