namespace dsbaglanti {
public partial class Form1 : Form {
OleDbConnection bag = new OleDbConnection("Provider=Microsoft.ACE.Oledb.12.0; Data Source=fatih.accdb");
OleDbDataAdapter dtada;
OleDbCommand cmd;
DataSet dtst;
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
dtada = new OleDbDataAdapter("Select *from ogrenci", bag);
dtst = new DataSet();
bag.Open();
dtada.Fill(dtst, "ogrenci");
dataGridView1.DataSource = dtst.Tables["ogrenci"];
bag.Close();
}
private void button1_Click(object sender, EventArgs e) // EKLE BUTONU {
cmd = new OleDbCommand();
bag.Open();
cmd.Connection = bag;
cmd.CommandText = "insert into ogrenci (ogr_no,ogr_ad,ogr_soyad)
values ('" + tbno.Text + "','" + tbad.Text + "','" + tbsoyad.Text + "')";
cmd.ExecuteNonQuery();
bag.Close();
}
private void button2_Click(object sender, EventArgs e) //GÜNCELLE BUTONU {
cmd = new OleDbCommand("update ogrenci set ogr_ad='" + tbad.Text + "',ogr_soyad='" + tbsoyad.Text + "' where ogr_no="+tbno.Text+"", bag);
bag.Open();
cmd.ExecuteNonQuery();
bag.Close();
}
private void button3_Click(object sender, EventArgs e) //SİLME BUTONU {
cmd = new OleDbCommand();
bag.Open();
cmd.Connection = bag;
cmd.CommandText = "delete from ogrenci where ogr_no="+tbno.Text+"";
cmd.ExecuteNonQuery();
bag.Close();
}