请教高手究竟是什么问题?
是关于一个留言本,部分代码如下:
public class info : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataList dltBoard;
protected System.Web.UI.WebControls.Label lblName;
protected System.Web.UI.WebControls.TextBox txtTheme;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtContent;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.Button btnOK;
SqlConnection cn;
SqlCommand cmd;
SqlDataReader dr;
SqlDataAdapter da;
DataSet ds;
int i;
string strConn,strSQL;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(Session.Count==0) Page.Response.Redirect("default.aspx");
else
if(Session["uid"].ToString()=="") Page.Response.Redirect("default.aspx");
strConn = ConfigurationSettings.AppSettings["SQLConnectionString"];
strSQL="select info_id,info_title,id,editer,info_cnt from info where class_id="+Page.Request["clid"].ToString()+" and del_flag='0' ORDER BY info_id DESC";
cn=new SqlConnection(strConn);
cn.Open();
da=new SqlDataAdapter(strSQL,cn);
ds=new DataSet();
da.Fill(ds,"info");
ds.Tables["info"].Columns.Add("editinfo");
ds.Tables["info"].Columns.Add("editurl");
ds.Tables["info"].Columns.Add("delurl");
ds.Tables["info"].Columns.Add("name");
for(i=0;i<ds.Tables[0].Rows.Count;i++)
{
strSQL="select name from userreg where id="+ds.Tables[0].Rows[i]["id"].ToString();
cmd=new SqlCommand(strSQL,cn);
dr=cmd.ExecuteReader();
while(dr.Read())
ds.Tables[0].Rows[i]["name"]=dr[0].ToString();
cmd.Dispose();
dr.Close();
}
for(i=0;i<ds.Tables[0].Rows.Count;i++)
strSQL="select admin1,admin2,admin3 from class where class_id="+Page.Request["clid"].ToString();
cmd=new SqlCommand(strSQL,cn);
dr=cmd.ExecuteReader();
while(dr.Read())
{
for(i=0;i<ds.Tables[0].Rows.Count;i++)
{
if(Session["uid"].ToString()==dr[0].ToString()|Session["uid"].ToString()==dr[1].ToString())//为管理员添加固顶选项
if(ds.Tables[0].Rows[i]["id"].ToString()==Session["uid"].ToString()|Session["uid"].ToString()==dr[0].ToString()|Session["uid"].ToString()==dr[1].ToString())//为管理员和贴子作者添加编辑删除选项
{
ds.Tables[0].Rows[i]["editurl"]="<A href=Editinfo.aspx?infoid="+ds.Tables[0].Rows[i]["info_id"].ToString()+">[编辑]</A>";
ds.Tables[0].Rows[i]["delurl"]="<A href=delinfo.aspx?infoid="+ds.Tables[0].Rows[i]["info_id"].ToString()+">[删除]</A>";
}
}
}
cmd.Dispose();
dr.Close();
strSQL="select name from userreg where id="+Session["uid"].ToString();
cmd=new SqlCommand(strSQL,cn);
dr=cmd.ExecuteReader();
while(dr.Read())
lblName.Text=dr[0].ToString();
cmd.Dispose();
dr.Close();
dltBoard.DataSource=ds.Tables["info"].DefaultView;
dltBoard.DataBind();
ds.Dispose();
cn.Close();
}