dynamically insert, update, delete datas in datagirdview in dot net



This is A C# Practice code:
        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 dataentry
        {
            public partial class Form5 : Form
            {
                public Form5()
                {
                    InitializeComponent();
                }
                SqlConnection abc = new SqlConnection("Data Source=.;Initial Catalog=DATAENTRY;Integrated Security=True;Pooling=False");
                
                SqlDataAdapter asdf;
                DataTable table;
                SqlCommandBuilder builder;
                DataSet sd;

                private void button1_Click(object sender, EventArgs e)
                {
                    asdf = new SqlDataAdapter(@"SELECT ID, NAME, GENDER, AGE, SALARY, TAX, STATUS FROM REGISTER", abc);
                    table = new DataTable();
                    asdf.Fill(table);
                    dataGridView1.DataSource = table;
                }

                private void button2_Click(object sender, EventArgs e)
                {
                   
                        builder = new SqlCommandBuilder(asdf);
                        asdf.Update(table);
                        
                       

                       
                   
                }
            }
        }

Video For Result:


Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Facebook Comment