为什么老是显示登录失败?
protected void Button1_Click(object sender, EventArgs e){
try
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = WebConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
conn.Open();
SqlCommand cmd = new SqlCommand("select [name],password from te", conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds,"te");
SqlDataReader dr = cmd.ExecuteReader();
string name = Convert.ToString(dr);
dr.Close();
SqlDataReader dr1 = cmd.ExecuteReader();
string password = Convert.ToString(dr1);
Response.Write(name);
if(txtName.Text.ToString()==name&&txtPassword.Text.ToString()==password)
{
Response.Write("登录成功");
}
else
{
Response.Write("登录失败");
}
dr1.Close();
conn.Close();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.txtName.Text = "";
this.txtPassword.Text = "";
}
}