{"id":2724,"date":"2026-05-21T09:59:41","date_gmt":"2026-05-21T06:59:41","guid":{"rendered":"https:\/\/www.aydiner.gen.tr\/?p=2724"},"modified":"2026-05-21T09:59:41","modified_gmt":"2026-05-21T06:59:41","slug":"kutuphane-cvp","status":"publish","type":"post","link":"https:\/\/www.aydiner.gen.tr\/index.php\/2026\/05\/21\/kutuphane-cvp\/","title":{"rendered":"k\u00fct\u00fcphane cvp"},"content":{"rendered":"<p>&#8212; 1. Veritaban\u0131 Olu\u015fturma<br \/>\nCREATE DATABASE KutuphaneDB;<br \/>\nGO<\/p>\n<p>USE KutuphaneDB;<br \/>\nGO<\/p>\n<p>&#8212; 2. Tablo Olu\u015fturma<br \/>\nCREATE TABLE Kitaplar (<br \/>\nKitapID INT IDENTITY(1,1) PRIMARY KEY,<br \/>\nKitapAdi NVARCHAR(100) NOT NULL,<br \/>\nYazar NVARCHAR(50) NOT NULL,<br \/>\nSayfaSayisi INT,<br \/>\nYayinEvi NVARCHAR(50)<br \/>\n);<\/p>\n<p>using System;<br \/>\nusing System.Data;<br \/>\nusing System.Windows.Forms;<br \/>\nusing System.Data.SqlClient; \/\/ SQL Ba\u011flant\u0131s\u0131 i\u00e7in gerekli k\u00fct\u00fcphane<\/p>\n<p>namespace KutuphaneProjesi<br \/>\n{<br \/>\npublic partial class Form1 : Form<br \/>\n{<br \/>\npublic Form1()<br \/>\n{<br \/>\nInitializeComponent();<br \/>\n}<\/p>\n<p>\/\/ Ba\u011flant\u0131 c\u00fcmlesi (Server ismi laboratuvardaki bilgisayarlara g\u00f6re g\u00fcncellenmelidir)<br \/>\nSqlConnection baglanti = new SqlConnection(&#8220;Data Source=.;Initial Catalog=KutuphaneDB;Integrated Security=True&#8221;);<\/p>\n<p>\/\/ 1. Listeleme Fonksiyonu<br \/>\nvoid KitapListele()<br \/>\n{<br \/>\ntry<br \/>\n{<br \/>\nbaglanti.Open();<br \/>\nSqlDataAdapter da = new SqlDataAdapter(&#8220;SELECT * FROM Kitaplar&#8221;, baglanti);<br \/>\nDataTable dt = new DataTable();<br \/>\nda.Fill(dt);<br \/>\ndgvKitaplar.DataSource = dt;<br \/>\n}<br \/>\ncatch (Exception hata)<br \/>\n{<br \/>\nMessageBox.Show(&#8220;Hata olu\u015ftu: &#8221; + hata.Message);<br \/>\n}<br \/>\nfinally<br \/>\n{<br \/>\nbaglanti.Close();<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/ Form a\u00e7\u0131ld\u0131\u011f\u0131nda listeleme tetiklenir<br \/>\nprivate void Form1_Load(object sender, EventArgs e)<br \/>\n{<br \/>\nKitapListele();<br \/>\n}<\/p>\n<p>\/\/ 2. Kaydetme Butonu<br \/>\nprivate void btnKaydet_Click(object sender, EventArgs e)<br \/>\n{<br \/>\ntry<br \/>\n{<br \/>\nbaglanti.Open();<br \/>\nstring sorgu = &#8220;INSERT INTO Kitaplar (KitapAdi, Yazar, SayfaSayisi, YayinEvi) VALUES (@p1, @p2, @p3, @p4)&#8221;;<br \/>\nSqlCommand komut = new SqlCommand(sorgu, baglanti);<\/p>\n<p>komut.Parameters.AddWithValue(&#8220;@p1&#8221;, txtKitapAdi.Text);<br \/>\nkomut.Parameters.AddWithValue(&#8220;@p2&#8221;, txtYazar.Text);<br \/>\nkomut.Parameters.AddWithValue(&#8220;@p3&#8221;, Convert.ToInt32(txtSayfaSayisi.Text));<br \/>\nkomut.Parameters.AddWithValue(&#8220;@p4&#8221;, txtYayinEvi.Text);<\/p>\n<p>komut.ExecuteNonQuery();<br \/>\nMessageBox.Show(&#8220;Kitap ba\u015far\u0131yla kaydedildi.&#8221;);<br \/>\n}<br \/>\ncatch (Exception hata)<br \/>\n{<br \/>\nMessageBox.Show(&#8220;Kay\u0131t hatas\u0131: &#8221; + hata.Message);<br \/>\n}<br \/>\nfinally<br \/>\n{<br \/>\nbaglanti.Close();<br \/>\nKitapListele(); \/\/ Listeyi g\u00fcncelle<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/ 3. Silme Butonu<br \/>\nprivate void btnSil_Click(object sender, EventArgs e)<br \/>\n{<br \/>\nif (dgvKitaplar.SelectedRows.Count &gt; 0)<br \/>\n{<br \/>\ntry<br \/>\n{<br \/>\nbaglanti.Open();<br \/>\nstring sorgu = &#8220;DELETE FROM Kitaplar WHERE KitapID = @id&#8221;;<br \/>\nSqlCommand komut = new SqlCommand(sorgu, baglanti);<\/p>\n<p>\/\/ DataGridView&#8217;de se\u00e7ili sat\u0131r\u0131n ilk h\u00fccresindeki (KitapID) de\u011ferini al\u0131r<br \/>\nint secilenId = Convert.ToInt32(dgvKitaplar.SelectedRows[0].Cells[&#8220;KitapID&#8221;].Value);<br \/>\nkomut.Parameters.AddWithValue(&#8220;@id&#8221;, secilenId);<\/p>\n<p>komut.ExecuteNonQuery();<br \/>\nMessageBox.Show(&#8220;Kitap ba\u015far\u0131yla silindi.&#8221;);<br \/>\n}<br \/>\ncatch (Exception hata)<br \/>\n{<br \/>\nMessageBox.Show(&#8220;Silme hatas\u0131: &#8221; + hata.Message);<br \/>\n}<br \/>\nfinally<br \/>\n{<br \/>\nbaglanti.Close();<br \/>\nKitapListele(); \/\/ Listeyi g\u00fcncelle<br \/>\n}<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nMessageBox.Show(&#8220;L\u00fctfen silmek istedi\u011finiz sat\u0131r\u0131 DataGridView \u00fczerinden se\u00e7in!&#8221;);<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8212; 1. Veritaban\u0131 Olu\u015fturma CREATE DATABASE KutuphaneDB; GO USE KutuphaneDB; GO &#8212; 2. Tablo Olu\u015fturma CREATE TABLE Kitaplar ( KitapID [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2724","post","type-post","status-publish","format-standard","hentry","category-genel"],"_links":{"self":[{"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/posts\/2724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/comments?post=2724"}],"version-history":[{"count":1,"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/posts\/2724\/revisions"}],"predecessor-version":[{"id":2725,"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/posts\/2724\/revisions\/2725"}],"wp:attachment":[{"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/media?parent=2724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/categories?post=2724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aydiner.gen.tr\/index.php\/wp-json\/wp\/v2\/tags?post=2724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}