emmanuel okoh

emmanuel okoh

  • NA
  • 14
  • 8.4k

login with MySQL(Am using wamp server)

Aug 14 2014 9:18 AM
Hello,Please can someone help me,am trying to create login with MySQL database.Am having this error-"Access denied for user 'root'@'localhost'(using password:YES)"

These are my code on the front end-

try
            {
                string myConnection = "datasource=localhost;port=3306;username=root;password=root";
                MySqlConnection myConn = new MySqlConnection(myConnection);
                MySqlCommand SelectCommand = new MySqlCommand("select * from jedo.tbllogin where userid='" + this.texUname.Text + "' and password='" + this.textPword.Text + "';", myConn);
                MySqlDataReader myReader;
                myConn.Open();
                myReader = SelectCommand.ExecuteReader();
                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }
                if (count == 1)
                {
                    MessageBox.Show("Username and password is correct");
                }
                else if (count > 1)
                {
                    MessageBox.Show("Duplicate Username and password...Access denied");
                }
                else
                    MessageBox.Show("Username and password is not correct...Please try again");
                myConn.Close();
                }
                catch (Exception ex)
                {
                MessageBox.Show(ex.Message);
                }



At the back end.
"

Field Type Collation Attributes Null Default Extra Action
varchar(100) latin1_swedish_ci
No a
Browse distinct values Change Drop Primary Unique Index Fulltext
varchar(100) latin1_bin
No a
Browse distinct values Change Drop Primary Unique Index Fulltext
"

Answers (1)