protected void Button1_Click2(object sender, EventArgs e)
    {
        Session["UserID"] = txtUserID.Text;
        Session["UserName"] = txtUserName.Text;        DataCon myCon = new DataCon();
        SqlConnection sqlconn = myCon.getCon();
        sqlconn.Open();
             if (AdminChk1.Checked==true)
        {
       
            string str = "select count(*) from tb_Admin where AdminID='" + txtUserID.Text + "'and AdminName='" + txtUserName + "' and AdminPwd='" + txtPsw.Text + "' ";
            
            SqlCommand sqlcom = new SqlCommand(str, sqlconn);
            
            int count=Convert.ToInt32(sqlcom.ExecuteNonQuery());            if(count>0)
            {
               Page.Response.Redirect("AdminMain.aspx");
            }
           else 
            {
                Response.Write("<script>  window.alert('登陆失败!') </script>");
            }
        }        else
        {
          
            string str = "select count(*) from tb_User where UserID='" + txtUserID.Text + "'and UserName='" + txtUserName.Text + "'and UserPwd='" + txtPsw.Text + "'";
            SqlCommand sqlcom = new SqlCommand(str, sqlconn);
            int count=Convert.ToInt32(sqlcom.ExecuteNonQuery());            if(count>0)
            {
                Response.Redirect("UserMain.aspx");
            }
            else 
            {                Response.Write("<script>  window.alert('登陆失败!') </script>");
            }
     
         }
        sqlconn.Close();    }
我谢了一个DataCon类 ,用来连接数据库的:代码如下public DataCon()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
    public SqlConnection getCon()
    {
        string sqlCon = "Data Source=(local);Initial Catalog=db_BBS;Integrated Security=True";
        SqlConnection mycon = new SqlConnection(sqlCon);
        return mycon;
    }
运行那个代码之后输入的用户名正确的情况下也显示登录失败,不知道是什么原因,请各位指教一下