protected void Application_Start(Object sender,EventArgs e)
{
    SqlConnection con=new SqlConnection("server=.;database=countPeople;uid=sa;pwd=sa;");
    con.Open();
   SqlCommand cmd=new SqlCommand("select * from countPeople",con);
   int count=Convert.ToInt32(cmd.ExecuteScalar());
   con.Close();
   Application["totol"]=count;
   Application["online"]=0;
}

protected void Session_Start(Object sender,EventArgs e)
{
   Session.Timeout=1;
   Application.Lock();
   Application["online"]=(int)Application["online"]+1;
Application["totol"]=(int)application["totol"]+1;
Application.UnLock();
}

protected void Session_End(Object sender,EventArgs e)
{
   Application.Lock();
   Application["online"]=(int)Application["online"]-1;
   Application.UnLock();
}

protected void Application_End(Object sender,EventArgs e)
{
SqlConnection con=new SqlConnection("server=;database=countPeople;uid=sa;pwd=sa;");
con.Open();
SqlCommand cmd=new SqlCommand("update countPeople set num="+Application["totole"].ToString(),con);

cmd.ExecuteNoQuery();

con.Close();


}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-21
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
相关资源
相似解决方案