protected void SetDestinationURL(object sender, EventArgs e)
{
if (loginMember())
Response.Redirect("~/Member/Home.aspx?Username=" + txtUsername.Text);
else if (loginManager())
Response.Redirect("~/Manager/Home.aspx?Username=" + txtUsername.Text);
else
Alert.Show("Unauthorized User Access");
}
protected Boolean loginMember()
{
SqlConnection conLogin = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
SqlCommand cmdLogin = new SqlCommand("SELECT Username, Password FROM Member WHERE (Username=@ID AND Password=@Pass)", conLogin);
conLogin.Open();
cmdLogin.Parameters.AddWithValue("@ID", txtUsername.Text);
cmdLogin.Parameters.AddWithValue("@Pass", txtPassword.Text);
SqlDataReader myReader = cmdLogin.ExecuteReader();
if (myReader.Read())
return true;
else
return false;
myReader.Close();
conLogin.Close();
}
I don't see anything wrong with my Database connection and the SELECT statement.
My database do have the correct Data and also those text box ID are exactly correct.
But it keep return me false and result in "Unauthorized User Access".
Before it don't have this problem, working fine. But it happen in Sudden. :/