Ejemplo n.º 1
0
        void Button1Click(object sender, EventArgs e)
        {
            Koneksi sambung = new Koneksi();

            try{
                sambung.buka();
                MessageBox.Show("Berhasil Koneksi Database", "Konfirmasi");
                this.Hide();
                FormOperationDML tampil = new FormOperationDML();
                tampil.ShowDialog();
            }
            catch (MySqlException ex)
            {
                switch (ex.Number)
                {
                case 0:
                { MessageBox.Show("Koneksi Gagal", "Konfirmasi"); }
                break;

                case 1045:
                { MessageBox.Show("Username atau Password Salah", "Konfirmasi"); }
                break;
                }
            }
        }
Ejemplo n.º 2
0
        void SavetodbClick(object sender, EventArgs e)
        {
            sambung = new Koneksi();
            sql     = "INSERT INTO mahasiswa (stb, nama, alamat, nilai_tugas, nilai_mid, nilai_final, nilai_akhir, " +
                      "nilai_huruf, keterangan) " +
                      "VALUES ('" + inputstb.Text + "', '" + inputnama.Text + "', '" + alamat.Text + "', " + inputNT.Text + ", " + inputMID.Text + ", " + inputFinal.Text + ", " + inputFinal.Text + ", '" + nilaihuruf.Text + "', " +
                      "'" + ket.Text + "')";

            try{
                sambung.buka();
                query   = new MySqlCommand(sql, sambung.koneksi);
                adapter = new MySqlDataAdapter(query);
                query.ExecuteNonQuery();
                MessageBox.Show("Data Berhasil Disimpan !!", "information");

                this.Close();
            } catch (Exception er) {
                MessageBox.Show(er.Message);
            }

            FormOperationDML show = new FormOperationDML();

            show.Refresh();
            show.TampilDalamTable();

            sambung.tutup();
        }