Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnLogin_Click(object sender, EventArgs e)
- {
- progressPanel1.Visible = true;
- Thread thread = new Thread(new ThreadStart(logadmin));
- thread.Start();
- }
- public void logadmin()
- {
- if (string.IsNullOrWhiteSpace(tbUsername.Text))
- { MessageBox.Show("Enter username"); tbUsername.Focus(); }
- else if (string.IsNullOrWhiteSpace(tbPassword.Text))
- { MessageBox.Show("Enter password"); tbPassword.Focus(); }
- else
- {
- connection.Close();
- try
- {
- MySqlCommand cmd = new MySqlCommand("select * from usertbl where Username = '" + tbUsername.Text + "' and Password = '" + tbPassword.Text + "'", connection);
- connection.Open();
- reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- count = count + 1;
- }
- if (count == 1)
- {
- Form1 ma = new Form1();
- ma.Show();
- connection.Close();
- this.Hide();
- }
- else
- {
- MessageBox.Show("Log-in Failed!");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
Add Comment
Please, Sign In to add comment