查找数据库上打开的连接数 [英] find number of open connection on database

查看:92
本文介绍了查找数据库上打开的连接数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Web应用程序位于asp.net 2.0,c#2.0和sql server 208中,我如何在sql server 2008数据库中找到打开的连接数。又有什么方法可以清除连接池。因为我的网站是托管的在共享主机上,他们提供的连接数量有限。在我的求婚中,我已关闭所有使用后的连接,但仍然收到挂起数据库的警告。

My web application is in asp.net 2.0,c#2.0 and sql server 208 how can i find number of open connections on my sql server 2008 database.and is there any way to clear connection pool.because my site is hosted on shared hosting and they have provided limited connections. In my codding i have closed all the connection after use, but still i am getting warning for suspending database.

有人可以告诉我如何在数据库中找到打开的连接吗?

Can any one tell me how to find number open connections on database and and how to clear connection pool.

i在连接语句中使用了using,并在finally块中使用后关闭了所有连接。因此,尽管有错误,但它会关闭选择的连接。

i used using statements for connections and closed all connections after used in finally block. so though there is error it closes oped connections.

预先感谢。

推荐答案

这显示了连接数每个数据库:

This shows the number of connections per each DB:

SELECT 
    DB_NAME(dbid) as DBName, 
    COUNT(dbid) as NoOfConnections,
    loginame as LoginName
FROM
    sys.sysprocesses
WHERE 
    dbid > 0
GROUP BY 
    dbid, loginame

这给出了总连接数:

SELECT 
    COUNT(dbid) as TotalConnections
FROM
    sys.sysprocesses
WHERE 
    dbid > 0

从c#中,您可以遵循:

http://www.c-sharpcorner.com/UploadFile/dsdaf/ConnPooling07262006093645AM/ConnPooling.aspx
另一个很好的参考可以在以下位置找到:

http://www.wduffy .co.uk / blog / monitoring-database-connections /

From c#, you can follow :
http://www.c-sharpcorner.com/UploadFile/dsdaf/ConnPooling07262006093645AM/ConnPooling.aspx Another good reference can be found at :
http://www.wduffy.co.uk/blog/monitoring-database-connections/

调用静态方法 ReleaseObjectPool OleDbConnection 上-请参见 http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbconnection.releaseobjectpool.aspx

Call the static method ReleaseObjectPool on the the OleDbConnection - see http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbconnection.releaseobjectpool.aspx

这篇关于查找数据库上打开的连接数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆