代码末尾的标签(以粗体突出显示)不显示从sql server数据库获取的数据,并且在运行代码时为空 . 我试过if(dt.Rows.Count> 0)和var table = ds2.Tables [0]; if(dt.Rows.Count> 0)两者 . 请回复此查询 .

namespace WebApplication1
{
    public partial class Response : System.Web.UI.Page
    {

        SqlCommand cmd = new SqlCommand();
        SqlConnection con2 = new SqlConnection();
        SqlDataAdapter sda2 = new SqlDataAdapter();
        DataSet ds2 = new DataSet();
      //in between code

        public void showdata()
        {
            cmd.CommandText = "Select * from signup1 where usid=''"+Session["user"]+"";
            cmd.Connection = con2;
            sda2.SelectCommand = cmd;
            sda2.Fill(ds2);
            Label1.Text = "Thank you! Your sign up was successful. Below are the details you entered, please verify:";
                **Label2.Text = "First Name: " + ds2.Tables[0].Rows[0]["fname"].ToString();
                Label3.Text = "Last Name: " + ds2.Tables[0].Rows[0]["lname"].ToString();
                Label4.Text = "UserID: " + ds2.Tables[0].Rows[0]["usid"].ToString();
                Label5.Text = "Password: " + ds2.Tables[0].Rows[0]["pswd"].ToString();
                Label6.Text = "Email: " + ds2.Tables[0].Rows[0]["eid"].ToString();
                Label7.Text = "Security Question: " + ds2.Tables[0].Rows[0]["sq"].ToString();
                Label8.Text = "Security Answer: " + ds2.Tables[0].Rows[0]["sa"].ToString();**
            }
        }
    }
}