Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MySql.Data.MySqlClient;
- ...
- private void buttonOk_Click(object sender, EventArgs e)
- {
- timer2.Start();
- }
- public static string Datasource = "localhost";
- public static string Port = "3306";
- public static string InitialCatalog = "user";
- public static string Username = "user";
- public static string Password = "pass";
- //MySql
- MySqlConnection connection = new MySqlConnection("datasource=" + Datasource + ";port=" + Port + ";Initial Catalog='" + InitialCatalog + "';username=" + Username + ";password=" + Password);
- MySqlDataAdapter adapter;
- DataTable table = new DataTable();
- public void MySqlConnect()
- {
- adapter = new MySqlDataAdapter("SELECT `username`, `password` FROM `users` WHERE `username` = '" + textBoxUsername.Text + "' AND `password` = '" + textBoxPassword.Text + "'", connection);
- adapter.Fill(table); //PROBLEM
- if (table.Rows.Count <= 0)
- {
- panel1.Height = 0;
- labelMessage.ForeColor = Color.Red;
- labelMessage.Text = "Username Or Password Are Invalid";
- timer1.Start();
- }
- else
- {
- panel1.Height = 0;
- labelMessage.ForeColor = Color.Green;
- labelMessage.Text = "Login Successfully";
- timer1.Start();
- }
- table.Clear();
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (panel1.Height != 100)
- {
- panel1.Height = panel1.Height + 5;
- if (panel1.Height == 100)
- {
- timer1.Stop();
- }
- }
- }
- private void timer2_Tick(object sender, EventArgs e)
- {
- if (panel1.Height != 0)
- {
- panel1.Height = panel1.Height - 5;
- if (panel1.Height == 0)
- {
- timer2.Stop();
- }
- }
- }
- private void checkBoxShowPass_CheckedChanged(object sender, EventArgs e)
- {
- if (checkBoxShowPass.Checked)
- {
- textBoxPassword.UseSystemPasswordChar = true;
- }
- else
- {
- textBoxPassword.UseSystemPasswordChar = false;
- }
- }
- ...
Add Comment
Please, Sign In to add comment