大家帮我看一下留言板的一部分代码
public partial class Ex09_05 : System.Web.UI.Page
{
protected SqlConnection myConnection = new SqlConnection();
protected void Page_Load(object sender, EventArgs e)
{
if (Session.Count == 0)
{
Response.Redirect( "Ex09_01.aspx ");
}
else
{
if (!IsPostBack)
{
postID = Request[ "PostID "];
}
myConnection.ConnectionString = "server=Localhost;uid=sa;pwd=sa;database=Aspnet ";
BindData();
}
}
private void BindData()
{
string selCmd1 = "select * from Ex09_GuestBook where PostID= " + postID;
SqlDataAdapter da1 = new SqlDataAdapter(selCmd1, myConnection);
string selCmd2 = "select * from Ex09_GuestBook where ParentID= " + postID;
SqlDataAdapter da2 = new SqlDataAdapter(selCmd2, myConnection);
DataSet ds = new DataSet();
da1.Fill(ds, "host ");
da2.Fill(ds, "guest ");
Label1.Text = ds.Tables[ "host "].Rows[0][4].ToString();
int reCount = ds.Tables[ "guest "].Rows.Count;
Label2.Text = reCount.ToString();
Label3.Text = ds.Tables[ "host "].Rows[0][2].ToString();
Label4.Text = ds.Tables[ "host "].Rows[0][4].ToString();
HyperLink1.Text = ds.Tables[ "host "].Rows[0][3].ToString();