0
        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. :/

2
Contributors
2
Replies
17
Views
3 Years
Discussion Span
Last Post by gahhon
0

But it keep return me false and result in "Unauthorized User Access".

I assume you realize it was a permission issue, not really related to the code you provided.

0

Hmm.. yeah. Reason is when i page_load i forgot put if(!PostBack) condition, and i clear all data, thus no value passing. -o-

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.