public static bool NotEkle(Not not) { bool eklendi = false; MySqlConnection connection = null; try { string connectionString = "SERVER=localhost;DATABASE=OgrenciYonetimSistemi; UID=root;PASSWORD=hy050491;"; connection = new MySqlConnection(connectionString); connection.Open(); string query = "INSERT INTO notlar (Vize1, Vize2, Final) VALUES ('" + not.Vize1+ "','"+not.Vize2+"','"+not.Final+"')"; //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connection); int sonucDeger = cmd.ExecuteNonQuery(); if (sonucDeger > 0) eklendi = true; } catch (Exception ex) { eklendi = false; } finally { connection.Close(); } return eklendi; }
public void NotEkle() { Not not = new Not(); not.Vize1 = Convert.ToInt32(txtVize1.Text.Trim()); not.Vize2 = Convert.ToInt32(txtVize2.Text.Trim()); not.Final = Convert.ToInt32(txtFinal.Text.Trim()); NotBL.NotEkle(not); }