alaa

alaa

  • NA
  • 166
  • 51k

test field value in datatables

Jun 19 2014 10:53 AM
hi 
i want to select username and password for only user who are confirmed from admin else alret message that it is still un confirmed this my code behind which i try

  public bool Login(string user, string pass)
    {


        string sel = string.Format("SELECT * FROM Tbl_Users WHERE U_UserName ='{0}' and U_PassWord ='{1}'", user, pass);
        DataTable tbl = Search(sel); 
        if ((tbl.Rows[13] = true) && tbl.Rows.Count == 1)
            return true;
        else
        {
            return flase;
        }
    } 


the tbl.Rows[13]  is for field index 


 protected void btnlogin_Click(object sender, EventArgs e)
    {
        Mem m = new Mem();


        if (m.Login(txtuser.Text, txtpass.Text) == true)
        {
            utility.CreateCookie("login", new string[] {"U"},
                new string[] {txtuser.Text}, ChkReM.Checked, Response);
                Response.Write("<script> alert('login success');</script>");
                Redirect(txtuser.Text);
        }
        else if (m.Login(txtuser.Text, txtpass.Text) == false)
        {
        //    Response.Write("<script> alert('your account is not active');window.location='Default.aspx'; </script>");
        }
        else
        {
            Response.Write("<script> alert('error in user name or password');</script>");
        }
       
   }

Answers (3)