數據庫准備:建立一個表total裡面數據項為totals類型為varchar
語言環境:C#
global
<%@ Import Namespace=
<%@ Import Namespace=
<script language=
string strSelect;
SqlConnection conPubs;
SqlDataAdapter dadPubs;
DataSet dstTitles;
DataRow drowTitle;
void Session_Start(Object sender
{
if ( Application[
Application[
strSelect =
conPubs = new SqlConnection(@
dadPubs = new SqlDataAdapter(strSelect
dstTitles = new DataSet();
dadPubs
drowTitle = dstTitles
Application[
}
}
void Session_End() {
Application[
}
</script>
============================
SessionCount
void Page_Load(Object sender
{
int total =
string strSelect;
SqlConnection conPubs;
//要執行某項數據操作要用SqlCommand方式調用
SqlCommand cmdSql;
//為了防止同文檔裡的其他頁面在訪問時也進行累加運算
int intHits =
intHits = (int)Application[
intHits +=
Application[
lblSessionCount
total = (int)Application[
strSelect =
conPubs = new SqlConnection(@
cmdSql = new SqlCommand(strSelect
cmdSql
conPubs
cmdSql
conPubs
}
================上段代碼有個小問題
更改後
global
<%@ Import Namespace=
<%@ Import Namespace=
<script language=
string strSelect;
SqlConnection conPubs;
SqlDataAdapter dadPubs;
DataSet dstTitles;
DataRow drowTitle;
void Session_Start(Object sender
{
if ( Application[
Application[
strSelect =
conPubs = new SqlConnection(@
dadPubs = new SqlDataAdapter(strSelect
dstTitles = new DataSet();
dadPubs
drowTitle = dstTitles
Application[
}
}
void Session_End() {
Application[
}
</script>
SessionCount
<script language=
void Page_Load(Object sender
{
int total =
string strSelect;
SqlConnection conPubs;
//要執行某項數據操作要用SqlCommand方式調用
SqlCommand cmdSql;
//為了防止同文檔裡的其他頁面在訪問時也進行累加運算
int intHits =
intHits = (int)Application[
intHits +=
total = intHits;
lblSessionCount
strSelect =
conPubs = new SqlConnection(@
cmdSql = new SqlCommand(strSelect
cmdSql
conPubs
cmdSql
conPubs
Application[
}
</script>
From:http://tw.wingwit.com/Article/program/net/201311/13438.html