Database preparation: Create a table with data items of the totals type varchar 50 in total. net Language Environment: C # global. code in asax <% @ Import Namespace = "System. data "%> <% @ Import Namespace =" System. data. sqlClient "%> <script language =" C # "runat =" server "> string strSelect; SqlConnection conPubs; SqlDataAdapter dadPubs; DataSet dstTitles; DataRow drowTitle; void Session_Start (Object sender, eventArgs e) {if (Application ["SessionCount"] = null) {Application ["SessionCount"] = 0; strSelect = "SELECT totals From total "; conPubs = new SqlConnection (@ "Server = localhost; Integrated Security = SSPI; Database = test"); dadPubs = new SqlDataAdapter (strSelect, conPubs); dstTitles = new DataSet (); dadPubs. fill (dstTitles, "total"); drowTitle = dstTitles. tables ["total"]. rows [0]; Application ["SessionCount"] = System. convert. toInt32 (drowTitle ["totals"]. toString (). trim () ;}} void Session_End () {Application ["SessionCount"] = 0 ;} </script> ============================= SessionCount. code void Page_Load (Object sender, EventArgs e) in aspx {int total = 0; string strSelect; SqlConnection conPubs; // to execute a data operation, use SqlCommand to call SqlCommand prepare SQL; // to prevent other pages in the same document from accumulating int intHits = 0; intHits = (int) Application ["SessionCount"]; intHits + = 1; application ["SessionCount"] = intHits; lblSessionCount. text = Application ["SessionCount"]. toString (); total = (int) Application ["SessionCount"]; strSelect = "update total set totals = @ total"; conPubs = new SqlConnection (@ "Server = localhost; integrated Security = SSPI; Database = test "); explain SQL = new SqlCommand (strSelect, conPubs); explain SQL. parameters. add ("@ total", total); conPubs. open (); explain SQL. executeNonQuery (); conPubs. close () ;}====================== there is a small problem with the code above, that is, after a while, the value of Application ["SessionCount"] is changed to 0, and because an initial 0 is set, the previously saved value in the database is updated to 0. global. asax <% @ Import Namespace = "System. data "%> <% @ Import Namespace =" System. data. sqlClient "%> <script language =" C # "runat =" server "> string strSelect; SqlConnection conPubs; SqlDataAdapter dadPubs; DataSet dstTitles; DataRow drowTitle; void Session_Start (Object sender, eventArgs e) {if (Application ["SessionCount"] = null) {Application ["SessionCount"] = 0; strSelect = "SELECT totals From total "; conPubs = new SqlConnection (@ "Server = localhost; Integrated Security = SSPI; Database = test"); dadPubs = new SqlDataAdapter (strSelect, conPubs); dstTitles = new DataSet (); dadPubs. fill (dstTitles, "total"); drowTitle = dstTitles. tables ["total"]. rows [0]; Application ["SessionCount"] = System. convert. toInt32 (drowTitle ["totals"]. toString (). trim () ;}} void Session_End () {Application ["SessionCount"] = null ;}</script> ---------- SessionCount. aspx <script language = "C #" runat = "server"> void Page_Load (Object sender, EventArgs e) {int total = 0; string strSelect; SqlConnection conPubs; // to execute a data operation, use SqlCommand to call SqlCommand prepare SQL; // to prevent other pages in the same document from being accessed, the cumulative operation int intHits = 0; intHits = (int) Application ["SessionCount"]; intHits + = 1; total = intHits; lblSessionCount. text = intHits. toString (); strSelect = "update total set totals = @ total"; conPubs = new SqlConnection (@ "Server = localhost; Integrated Security = SSPI; Database = test "); explain SQL = new SqlCommand (strSelect, conPubs); explain SQL. parameters. add ("@ total", total); conPubs. open (); explain SQL. executeNonQuery (); conPubs. close (); Application ["SessionCount"] = null ;}</script>