C# Access Ekle, Sil, Ara, Güncelle

C# Access Ekle, Sil, Ara, Güncelle Programı

C# access bağlantısı ile basit veri tabanı işlemleri(Ekle, Sil, Ara, Güncelle) yapalım.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace veritabani_islemleri
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        OleDbConnection connect = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=database.accdb");
        OleDbCommand cmd = new OleDbCommand();
        OleDbDataReader read;
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("www.technoprogram.com");
        }
        private void Temizle()
        {
            textBox1.Clear();
            textBox2.Clear();
            textBox3.Clear();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
            {
                MessageBox.Show("Tüm alanları doldurunuz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            connect.Open();
            cmd.Connection = connect;
            cmd.CommandText=("INSERT INTO bilgiler(tc_no,adi,soyadi) VALUES('"+textBox1.Text+"','"+textBox2.Text+"','"+textBox3.Text+"')");
            cmd.ExecuteNonQuery();
            connect.Close();
            MessageBox.Show("Bilgiler Başarıyla Eklendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Geçerli Kimlik Numarası Giriniz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            DialogResult a;
            a = MessageBox.Show(textBox1.Text + " Kimlik Numaralı Kişiyi Silmek İstediğinizden Emin Misiniz.", "Bilgi", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            if (a == DialogResult.Yes)
            {
                connect.Open();
                cmd.Connection = connect;
                cmd.CommandText = ("Delete*From bilgiler Where tc_no='" + textBox1.Text + "'");
                cmd.ExecuteNonQuery();
                connect.Close();
                Temizle();
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "Numara Seçiniz...")
            {
                MessageBox.Show("Öğrenci numarasını giriniz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            connect.Open();
            cmd.Connection = connect;
            cmd.CommandText = ("Select*From bilgiler Where tc_no='" + textBox1.Text + "'");
            read = cmd.ExecuteReader();
            while (read.Read())
            {
                textBox1.Text = read["tc_no"].ToString();
                textBox2.Text = read["adi"].ToString();
                textBox3.Text = read["soyadi"].ToString();
            }
            read.Dispose();
            connect.Close();
            if (textBox1.Text==""||textBox2.Text=="")
	        {
                MessageBox.Show("Aradığınız Kişi bulunamadı.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
	        }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("T.C Kimlik Numarası Giriniz.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            connect.Open();
            cmd.Connection = connect;
            cmd.CommandText = ("UPDATE bilgiler SET tc_no='" + textBox1.Text + "',adi='" + textBox2.Text + "',soyadi='" + textBox3.Text + "'Where tc_no='" +textBox1.Text + "'");
            cmd.ExecuteNonQuery();
            connect.Close();
            MessageBox.Show("Bilgiler Güncellendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}
c# veri tabanı işlemleri

Dosya boyutu : 71 Kb

Virustotal Sonuçları : 0 / 55  Temiz

Rar şifresi : www.technoprogram.com

C# Access Ekle, Sil, Ara, Güncelle Programı Projesini İndir

İndirmek için tıklayın

Not:Reklamı geç butonuna tıkladıktan sonra indirme otomatik olarak başlayacaktır.

 

 

Ahmet Şenlik

.

You may also like...

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Bu site istenmeyenleri azaltmak için Akismet kullanır. Yorum verilerinizin nasıl işlendiğini öğrenin.