做了一个文章发布系统,在ShowArticle.aspx页面显示内容,因为我是通过sesseion显示文章内容,使得经常死机,我想改,请大家指教如何改?showArticle.aspx.cs部分代码:string sql = "select subject,A.deptId,deptName,deptColumnName,content,CONVERT(nvarchar(10),UPDATETIME,121) as UPDATETIME,author,CLICK from AppArticle A,AppDept D where A.deptId=D.deptId and ID=" + article_id + " ";
SqlConnection sqlCnn;
sqlCnn = DB.GetSqlConnection();
try
{
SqlCommand sqlCmm = new SqlCommand(sql, sqlCnn);
SqlDataReader dr = sqlCmm.ExecuteReader();
if (dr.Read())
{
Session["subject_show"] = dr["subject"].ToString();
Session["content_show"] = dr["content"].ToString();
}
dr.Close();
}
catch (Exception ex)
{
//显示错误或作相应处理
Response.Write("错误原因:" + ex.Message);
Response.End();
}
finally
{
sqlCnn.Close();
}
showArticle.aspx页面是:
标题:<%=Session["subject_show"]%>
文章内容:<%=Session["subject_show"]%>我不知道showArticle.aspx页面如何显示这些内容,现在用session显示,使得经常死机,请大家指点
SqlConnection sqlCnn;
sqlCnn = DB.GetSqlConnection();
try
{
SqlCommand sqlCmm = new SqlCommand(sql, sqlCnn);
SqlDataReader dr = sqlCmm.ExecuteReader();
if (dr.Read())
{
Session["subject_show"] = dr["subject"].ToString();
Session["content_show"] = dr["content"].ToString();
}
dr.Close();
}
catch (Exception ex)
{
//显示错误或作相应处理
Response.Write("错误原因:" + ex.Message);
Response.End();
}
finally
{
sqlCnn.Close();
}
showArticle.aspx页面是:
标题:<%=Session["subject_show"]%>
文章内容:<%=Session["subject_show"]%>我不知道showArticle.aspx页面如何显示这些内容,现在用session显示,使得经常死机,请大家指点
内容:<%=content%>.cs
protected string title, content;//声明全局变量title = dr["subject"].ToString();
content = dr["content"].ToString();
sqlCnn.Open()