当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > .NET 2.0获取数据库连接统计数据

ASP.NET
合理的网盟广告策略:如何规划与投放网盟广告
GoDaddy Backorder域名抢注经验分享
Google Analytics获得GOOGLE真正的收录网站数据指标
Visual Studio 2008 Team Suite简体中文正式版- 激活方法

ASP.NET 中的 .NET 2.0获取数据库连接统计数据


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 34 ::
收藏到网摘: n/a


  .NET 2.0中的SqlConnection多了一个StatisticsEnabled属性和ResetStatistics()、RetrieveStatistics()两个方法,用于获取SQLServer的连接统计数据。



  <%@ Import Namespace="System.Data" %>
  <%@ Import Namespace="System.Data.SqlClient" %>
  <%@ page language="C#" %>
  
  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