video burda http://rapidshare.com/files/337450276/csharpveritabani.mp4
orjinal yazı burda http://www.csharpkitabi.com/csharp-...sorgulama-kayit-ekleme-kayit-silme-islemleri/
kodlar burada
çalışan örnek ekte.
Video da her şey sırası ile yapılmıştır. Yani bir yerlerden bakıp ezbere yazmadım
yapabileceğiniz bütün hataları yada gözden kaçıracağınız noktaları tek tek anlatmaya çalıştım. Sessiz sadece yok sesli de ben yokum vivaldi var.
not sitedeki yazıyı buraya geçirene kadar google indexlemiş yuh diyorum.
orjinal yazı burda http://www.csharpkitabi.com/csharp-...sorgulama-kayit-ekleme-kayit-silme-islemleri/
kodlar burada
Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace veritabaniislemleri
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection baglanti = new SqlConnection();
DataTable tablo = new DataTable();
SqlDataAdapter adaptor = new SqlDataAdapter();
SqlCommand komut = new SqlCommand();
string baglantiParametresi = "Data Source=OZCAN;Initial Catalog=test;User ID=test;Password=123;";
private void button1_Click(object sender, EventArgs e)
{
baglanti.ConnectionString = baglantiParametresi;
baglanti.Open();
MessageBox.Show("Bağlantı Sağlandı");
baglanti.Close();
MessageBox.Show("Balantı Kesildi");
}
private void button2_Click(object sender, EventArgs e)
{
tablo.Clear();
baglanti.ConnectionString = baglantiParametresi;
baglanti.Open();
komut.Connection = baglanti;
string SQL = "select * from musteri";
komut.CommandText = SQL;
adaptor.SelectCommand = komut;
adaptor.Fill(tablo);
dataGridView1.DataSource = tablo;
baglanti.Close();
}
private void button3_Click(object sender, EventArgs e)
{
tablo.Clear();
baglanti.ConnectionString = baglantiParametresi;
baglanti.Open();
komut.Connection = baglanti;
string SQL = "select * from musteri order by no desc";
komut.CommandText = SQL;
adaptor.SelectCommand = komut;
adaptor.Fill(tablo);
dataGridView1.DataSource = tablo;
baglanti.Close();
}
private void button4_Click(object sender, EventArgs e)
{
tablo.Clear();
baglanti.ConnectionString = baglantiParametresi;
baglanti.Open();
komut.Connection = baglanti;
string SQL = "select * from musteri where no="+textBox1.Text;
komut.CommandText = SQL;
adaptor.SelectCommand = komut;
adaptor.Fill(tablo);
dataGridView1.DataSource = tablo;
baglanti.Close();
}
private void button5_Click(object sender, EventArgs e)
{
tablo.Clear();
baglanti.ConnectionString = baglantiParametresi;
baglanti.Open();
komut.Connection = baglanti;
string SQL = "insert into musteri (no,isim,soyisim) values ("+textBox2.Text+",'"+textBox3.Text+"','"+textBox4.Text+"')";
komut.CommandText = SQL;
komut.ExecuteNonQuery();
baglanti.Close();
button2_Click(sender,new EventArgs());
}
private void button6_Click(object sender, EventArgs e)
{
tablo.Clear();
baglanti.ConnectionString = baglantiParametresi;
baglanti.Open();
komut.Connection = baglanti;
string SQL = "delete from musteri where no="+textBox5.Text;
komut.CommandText = SQL;
komut.ExecuteNonQuery();
baglanti.Close();
button2_Click(sender, new EventArgs());
}
}
}
çalışan örnek ekte.
Video da her şey sırası ile yapılmıştır. Yani bir yerlerden bakıp ezbere yazmadım