简体   繁体   中英

DataTable.Rows.Count > 0 always false

i am trying to create a login page. my query works correctly but when it calls DataTable.Rows.Count>0 it always show false.

private void getLogin()
{
    Query = "select emailID,Password from Admin where emailID = @emailID and @emailID = @Password ";
    Command = new SqlCommand(Query, Connection);
    Command.Parameters.AddWithValue("@emailID", TxtLoginID.Value.Trim());
    Command.Parameters.AddWithValue("@Password", TxtPassword.Value.Trim());
    DAdapter.SelectCommand = Command;
    DataTable DTable = new DataTable();
    DAdapter.Fill(DTable);
    if (DTable.Rows.Count > 0)
    {
        Response.Redirect("admin.aspx");
    }
    else
    {
        lblError.Visible = true;
        lblError.Text = "Enter Valid E-Mail id and Password.";
    }
}

You can easily debug this code and confirm if the table has any rows. Also the query seems wrong. @emailId = @password seems wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM