Esempio n. 1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            /*
             * 2. Crypto
             */


            string Execute = "SELECT * FROM ID where USERNAME = '******'";

            MySqlConnection MySqlConnection = new MySqlConnection(SQLConnectionString);
            MySqlCommand    MySqlCommand    = new MySqlCommand(Execute, MySqlConnection);

            MySqlCommand.CommandTimeout = 30;
            MySqlDataReader MySqlReader;

            try
            {
                MySqlConnection.Open(); //Open the sql connection
                MySqlReader = MySqlCommand.ExecuteReader();

                if (MySqlReader.HasRows)
                {
                    MySqlReader.Read();

                    const int POS_PASSWD = 2; /*Naja geht halt so warum nicht global ? :=) */

                    if (textBoxPassword.Text == MySqlReader.GetString(POS_PASSWD))
                    {
                        MessageBox.Show("Login Successfull");
                    }
                    else
                    {
                        MessageBox.Show("Username or Password wrong");
                    }
                }
                else
                {
                    MessageBox.Show("Username or Password wrong");
                }
                MySqlConnection.Close(); //Closing the sql connection
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error");
            }

            textBoxUsername.Text = "";
            textBoxPassword.Text = "";
        }