示例#1
0
        public void OgrenciEkle(string ogrenciAdi, string ogrenciSoyadi, string telefon, string email)
        {
            Ogrenci yeniOgrenci = new Ogrenci(ogrenciAdi, ogrenciSoyadi, telefon, email);

            Ogrenciler.Add(yeniOgrenci);
            var connectionString = @"Server = DESKTOP-NCH3S9Q\SQLEXPRESS; Database = EgitimKayit; Integrated Security = true; ";
            var commandText      = "INSERT INTO Ogrenciler(Id,OgrenciAdi,OgrenciSoyadi,Telefon,Email) " +
                                   "VALUES('" + yeniOgrenci.Id + "','" + yeniOgrenci.OgrenciAdi + "','" + yeniOgrenci.OgrenciSoyadi + "'," +
                                   "'" + yeniOgrenci.Telefon + "','" + yeniOgrenci.Email + "')";
            SqlConnection con = new SqlConnection(connectionString);

            con.Open();
            SqlCommand command = new SqlCommand(commandText, con);

            command.ExecuteNonQuery();
            con.Close();
        }
示例#2
0
        public List <Ogrenci> OgrenciGetir()
        {
            Ogrenciler.Clear();
            var           connectionString = @"Server = DESKTOP-NCH3S9Q\SQLEXPRESS; Database = EgitimKayit; Integrated Security = true; ";
            SqlConnection con = new SqlConnection(connectionString);

            con.Open();
            SqlCommand    command = new SqlCommand("SELECT * FROM Ogrenciler", con);
            SqlDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                Ogrenci ogrenci = new Ogrenci(reader.GetGuid(0).ToString(), reader.GetString(1),
                                              reader.GetString(2), reader.GetString(3), reader.GetString(4));
                Ogrenciler.Add(ogrenci);
            }
            con.Close();
            return(Ogrenciler);
        }