public DataTable baca() { koneksi conn = new koneksi(); string sql = "select * from siswa where nis='" + this.textBox16.Text + "'"; DataTable dt = new DataTable(); try { conn.tampil(); MySqlCommand cmd = new MySqlCommand(sql, conn.konek); MySqlDataAdapter adp = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); adp.Fill(dt); bindingSource1.DataSource = dt; dataGridView1.DataSource = bindingSource1; bindingNavigator1.BindingSource = bindingSource1; } catch (Exception luk) { MessageBox.Show(luk.Message); } conn.tutup(); return(dt); }
public DataTable baca() { koneksi conn = new koneksi(); string sql = "select * from siswa"; DataTable dt = new DataTable(); try { conn.tampil(); MySqlCommand cmd = new MySqlCommand(sql, conn.konek); MySqlDataAdapter adp = new MySqlDataAdapter(cmd); cmd.ExecuteNonQuery(); adp.Fill(dt); } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.tutup(); return(dt); }
private void button3_Click(object sender, EventArgs e) { try { DialogResult di = MessageBox.Show("Edit Data?", "important", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (di == DialogResult.Yes) { koneksi conn = new koneksi(); conn.tampil(); conn.QUERY("update siswa set nama='" + this.textBox2.Text + "',alamat='" + textBox3.Text + "',jenkel='" + textBox4.Text + "',kelas='" + comboBox3.Text + "',kek_thn_lalu='" + textBox5.Text + "',daftar_ulang='" + textBox6.Text + "',spp1='" + comboBox1.Text + "',spp2='" + comboBox2.Text + "',spp3='" + textBox7.Text + "',sardik='" + textBox8.Text + "',lks='" + textBox9.Text + "',lainlain1='" + textBox10.Text + "',lainlain2='" + textBox11.Text + "',jumlah='" + textBox12.Text + "',keterangan='" + dateTimePicker1.Text + "'where nis='" + textBox1.Text + "'"); conn.tutup(); } else if (di == DialogResult.No) { } } catch (Exception kur) { MessageBox.Show(kur.Message); } }
private void button6_Click(object sender, EventArgs e) { DialogResult di = MessageBox.Show("Hapus Data?", "important", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (di == DialogResult.Yes) { try { koneksi conn = new koneksi(); conn.tampil(); conn.QUERY("delete from siswa where nis='" + this.textBox14.Text + "'"); MessageBox.Show("DIHAPUS"); conn.tutup(); } catch (Exception lul) { MessageBox.Show(lul.Message); } } else if (di == DialogResult.No) { } }