Code To INSERT INTO data in access Db using c#




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 DicleY
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection n = new SqlConnection();
            n.ConnectionString = "Data Source=LENOVO-PC;Initial Catalog=DicleYilmaz;Integrated Security=True";
            n.Open();
         
            SqlCommand d = new SqlCommand();
            d.Connection = n;
            d.CommandText = "Select * from Personel";
           d.CommandText = "INSERT INTO Personel (AD, SOYAD, DOGUMYERI, MAAS, CINSIYET, GOREV, ADRES, SUBEID) VALUES(@AD, @SOYAD, @DOGUMYERI, @MAAS, @CINSIYET, @GOREV, @ADRES, @SUBEID)";
            d.CommandType = CommandType.Text;
            d.Parameters.AddWithValue("@AD", textBox1.Text);
            d.Parameters.AddWithValue("@SOYAD", textBox2.Text);
            d.Parameters.AddWithValue("@DOGUMYERI", textBox3.Text);
            d.Parameters.AddWithValue("@MAAS", textBox4.Text);
            d.Parameters.AddWithValue("@SUBEID", textBox8.Text);
            d.Parameters.AddWithValue("@CINSIYET", textBox5.Text);
            d.Parameters.AddWithValue("@GOREV", textBox6.Text);
            d.Parameters.AddWithValue("@ADRES", textBox7.Text);
            d.ExecuteNonQuery();

         
         

        }

        private void Form1_Load(object sender, EventArgs e)
        {
       
        }
    }
}

Yorumlar

Popüler Yayınlar