0
        protected Boolean loginMember()
        {
            SqlConnection conLogin = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
            SqlCommand cmdLogin;
            conLogin.Open();
            cmdLogin = new SqlCommand("SELECT Username, Password FROM Member WHERE (UserName=@ID AND Password=@Pass)", conLogin);
            cmdLogin.Parameters.AddWithValue("@ID", txtID.Text);
            cmdLogin.Parameters.AddWithValue("@Pass", txtPassword.Text);
            SqlDataReader myReader = cmdLogin.ExecuteReader();
            if (myReader.Read())
                return true;
            else
                return false;   
        }

When i execute the login button will fire this event,
if return true to response.redirect("page2.aspx") otherwise will display a message box.
But after execute the login button, it show me this error and hightlighted
conLogin.Open();

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

If youget that message, then most likely line 3 failed to create a new object. Perhaps because the connection string is missing or invalid.

0

I think i figure what's the problem already.
The connection name is valid & correct but i didn't open again the web page instead of keep refreshing the previous one (old version; before modify)

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.