国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ASP.NET 2.0里輕松獲取數據庫連接統計數據

2019-11-18 19:33:35
字體:
來源:轉載
供稿:網友

    asp.net 2.0中的SqlConnection多了一個StatisticsEnabled屬性和ResetStatistics()、RetrieveStatistics()兩個方法,用于獲取SQLServer的連接統計數據。

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ page language="C#" %>
<script runat="server">
    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] + "<BR />";
        }
    }
</script>
<html>
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="Form1" runat="server" autocomplete="on">
        <asp:Label ID="Label1" Runat="server" Text=""></asp:Label>
    </form>
</body>
</html>

運行后的結果就是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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嘉峪关市| 浪卡子县| 哈密市| 永善县| 阿坝县| 绥宁县| 同德县| 中方县| 都江堰市| 古丈县| 盘山县| 潜江市| 集安市| 诸城市| 灵石县| 开封市| 博兴县| 太湖县| 长岛县| 文昌市| 思茅市| 涿鹿县| 乐平市| 福泉市| 大城县| 延津县| 伊宁市| 阿克陶县| 武义县| 宜州市| 名山县| 湟源县| 田东县| 宜黄县| 赞皇县| 江北区| 嘉兴市| 西林县| 昌吉市| 阳城县| 和龙市|