Reputation: 1
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.";
}
}
Upvotes: 0
Views: 477
Reputation: 11
You can easily debug this code and confirm if the table has any rows. Also the query seems wrong. @emailId = @password seems wrong.
Upvotes: 1