所属类别:.NET
文章作者:未知
特别推荐:免费发布信息 承包关键词~~抢爆了!HOT!
.NET 2.0中的SqlConnection多了一个StatisticsEnabled属性和ResetStatistics()、RetrieveStatistics()两个方法,用于获取SQLServer的连接统计数据。
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ page language="C#" %>
void Page_Load(object sender, EventArgs e)
{
string connString = "Northwind的连接串";
SqlConnection conn = new SqlConnection(connString);
conn.StatisticsEnabled = true;
conn.ResetStatistics();
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM Orders", conn);
SqlDataReader reader = cmd.ExecuteReader();
reader.Close();
conn.Close();
Hashtable ht = (Hashtable)conn.RetrieveStatistics();
foreach (string key in ht.Keys)
{
Label1.Text += "Key: " + key + " = " + ht[key] + "";
}
}
Untitled Page
运行后的结果就是SQLServer连接统计数据结果:
Key: NetworkServerTime = 0
Key: BytesReceived = 156913
Key: UnpreparedExecs = 1
Key: SumResultSets = 1
Key: SelectCount = 1
Key: PreparedExecs = 0
Key: ConnectionTime = 30
Key: ExecutionTime = 30
Key: Prepares = 0
Key: BuffersSent = 1
Key: SelectRows = 830
Key: ServerRoundtrips = 1
Key: CursorOpens = 0
Key: Transactions = 0
Key: BytesSent = 48
Key: BuffersReceived = 20
Key: IduRows = 0
Key: IduCount = 0 关闭本页
相关信息· 文件上传组件和其它组件的取代方案
· 人大校园网新认证系统Linux上网解决方法
· 实例:黑客入侵Linux操作系统
· 丿领先丶小郑
29282
11407
