Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void LoginButton_Click(object sender, RoutedEventArgs e)
- {
- string connectionString = "Server=localhost;Database=edtest;Uid=root;Password=; ";
- using (MySqlConnection db_connect = new MySqlConnection(connectionString))
- {
- try
- {
- db_connect.Open();
- MySqlCommand command = db_connect.CreateCommand();
- command.CommandType = CommandType.Text;
- command.CommandText = "select * from accounts where username='" + UsernameTextbox.Text + "' and userpass='" + PasswordBox.Password + "'";
- command.ExecuteNonQuery();
- DataTable dt = new DataTable();
- MySqlDataAdapter da = new MySqlDataAdapter(command);
- da.Fill(dt);
- int i = Convert.ToInt32(dt.Rows.Count.ToString());
- if (i == 0)
- {
- MessageBox.Show("Faild to login, please try again");
- }
- else
- {
- this.Hide();
- MainWindowLogged nw = new MainWindowLogged();
- nw.Show();
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement