Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string          connect            = "datasource=localhost;port=33068;username=Dnlpq66;password=irhN3e0c1Tzu;database=tabla";
            string          query              = "select * from login where user = '******' AND password = '******'";
            MySqlConnection databaseConnection = new MySqlConnection(connect);
            MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);

            commandDatabase.CommandTimeout = 60;
            MySqlDataReader reader;

            try
            {
                databaseConnection.Open();
                reader = commandDatabase.Executereader();
                if (reader.Read())
                {
                    MessageBox.Show("Bienvenido al Sistema");
                }
                else
                {
                    MessageBox.Show("Usuario o contraseña incorrecta");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        //Insert statement
        public void Insert()
        {
            try
            {
                string Query = "insert into mastercode(Etunimi,Sukunimi,Lahiosoite,Postinumero,Postitoimipaikka,Puhelinnumero,Sahkopostiosoite,Salasana) values('" + this.enimiBoxi.Text + "','"
                               + this.snimiBoxi.Text + "','" + this.osoiteBoxi.Text + "','" + this.pnumeroBoxi.Text + "','" + this.ptpBoxi.Text + "','" + this.puhelinBoxi.Text + "','" + this.emailBoxi.Text + "','" + this.salasanaBoxi.Text + "');";

                MySqlCommand MyCommand2 = new MySqlCommand(Query);

                MySqlDataReader MyReader2;

                connection.Open();

                MyReader2 = MyCommand2.Executereader();

                MessageBox.Show("Tiedot tallennettu");

                while (MyReader2.Read())
                {
                }
                connection.Close();
            }
            catch (Exeption ex)
            {
                MessageBox.Show(ex.Message);
            }
        }