private void button1_Click(object sender, EventArgs e) { MySqlCommand command = new MySqlCommand(); giris2 giris2 = new giris2(); try { command.Connection = bag; command.CommandText = "delete from ogrenci where numara ='" + label1.Text + "'"; bag.Open(); command.ExecuteNonQuery(); bag.Close(); MessageBox.Show("Başarıyla Silindi"); } catch { MessageBox.Show("Hata var"); } }
private void button2_Click(object sender, EventArgs e) { giris2 giris2 = new giris2(); String sql = String.Empty; MySqlCommand command = new MySqlCommand(); command.CommandText = "select parola from ogrenci where numara = " + textBox1.Text; command.Connection = bag; bag.Open(); try { sql = (string)command.ExecuteScalar(); if (textBox2.Text == sql) { String sql2 = String.Empty; MySqlCommand command2 = new MySqlCommand(); command2.CommandText = "select numara from ogrenci where numara = " + textBox1.Text; command2.Connection = bag; sql2 = (string)command2.ExecuteScalar(); giris2.label6.Text = sql2; String sql3 = String.Empty; MySqlCommand command3 = new MySqlCommand(); command3.CommandText = "select ad from ogrenci where numara = " + textBox1.Text; command3.Connection = bag; sql3 = (string)command3.ExecuteScalar(); giris2.label7.Text = sql3; String sql4 = String.Empty; MySqlCommand command4 = new MySqlCommand(); command4.CommandText = "select soyad from ogrenci where numara = " + textBox1.Text; command4.Connection = bag; sql4 = (string)command4.ExecuteScalar(); giris2.label8.Text = sql4; String sql5 = String.Empty; MySqlCommand command5 = new MySqlCommand(); command5.CommandText = "select sinif from ogrenci where numara = " + textBox1.Text; command5.Connection = bag; sql5 = (string)command5.ExecuteScalar(); giris2.label9.Text = sql5; String sql6 = String.Empty; MySqlCommand command6 = new MySqlCommand(); command6.CommandText = "select parola from ogrenci where numara = " + textBox1.Text; command6.Connection = bag; sql6 = (string)command6.ExecuteScalar(); giris2.label10.Text = sql6; giris2.ShowDialog(); } else { MessageBox.Show("giris basarisiz!!!"); } } catch { MessageBox.Show("giris basarisiz!!!"); } bag.Close(); }