Beispiel #1
0
        private void Sesion()
        {
            string          connect            = "datasource=localhost;port=3306;username=root;password=;database=formulario";
            string          query              = "SELECT * from user where user = '******'AND password='******'";
            MySqlConnection databaseConnection = new MySlConnection(connect);
            MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);

            commandDatabase.CommandTimeout = 60;
            MySqlDataReader reader;

            try
            {
                databaseConnection.Open();
                reader = commandDatabase.ExecuteReader();
                if (reader.Read())
                {
                    MessageBox.Show("Welcome User");
                }
                else
                {
                    MessageBox.Show("Error, Incorrect Data");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string          connect            = "datasource=localhost;port=3306;username=root;password=;database=formulario";
            string          query              = "INSERT INTO usuario(`ID`, `User`, `Password`) VALUES (NULL, '" + textuser.Text + "', '" + textpassword.Text + "')";
            MySqlConnection databaseConnection = new MySlConnection(connect);
            MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);

            commandDatabase.CommandTimeout = 60;
            MySqlDataReader reader;

            try
            {
                databaseConnection.Open();
                MySqlDataReader reader = commandDatabase.ExecuteReader();
                MessageBox.Show("Registered User");
                databaseConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }