Ado.net中SQLServer数据库连接池

  12:     {
  13:         using (SqlConnection conn = new SqlConnection(connStringUsePool))
  14:         {
  15:             conn.Open();
  16:             conn.Close();
  17:         }
  18:     }
  19:     DateTime end = DateTime.Now;
  20:     TimeSpan ts = end - start;
  21:     label1.Text = "使用连接池"+ts.Milliseconds.ToString();
  22:  
  23:     start = DateTime.Now;
  24:     for (int i = 0; i < count; i++)
  25:     {
  26:         using (SqlConnection conn = new SqlConnection(connStringUnUsePool))
  27:         {
  28:             conn.Open();
  29:             conn.Close();
  30:         }
  31:     }
  32:     end = DateTime.Now;
  33:     ts = end - start;
  34:     label2.Text = "不使用连接池" + ts.Milliseconds.ToString();
  35: }

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。