查询sqlserver数据库连接池中的连接数
问题描述:
程序迁移负载均衡环境后,有时会出现以下异常:
System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process.
怀疑是负载均衡把上次的连接超时中断了,而连接池中又引用了这个链接,于是在连接串中加了Pooling=false.但仍然会出现这个错误。想测试下是否仍然在使用连接池,想在每次连接前把连接池中的连接数打印到日志上。
需求:
能查询连接池中连接数的方法。