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

Member Avatar for LastMitch

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.