Click here to Skip to main content
15,891,943 members
Articles / Programming Languages / C#

DataBase Updation With DataGridView in simple steps

Rate me:
Please Sign up or sign in to vote.
1.00/5 (1 vote)
7 Dec 2011CPOL2 min read 29.3K   1.6K   3  
Here is a step by step process to update database through datagridview in Windows applications
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;

namespace gridViewTest
{
    public partial class testGrid : Form
    {
        public testGrid()
        {
            InitializeComponent();
        }

        private void testGrid_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'gridTestDataSet.Emp' table. You can move, or remove it, as needed.
            this.empTableAdapter.Fill(this.gridTestDataSet.Emp);

        }

        private void button3_Click(object sender, EventArgs e)
        {
            //Update button update dataset after insertion,upadtion or deletion
            DialogResult dr = MessageBox.Show("Are you sure to save Changes","Message",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Information);
            if (dr == DialogResult.Yes)
            {
                this.empTableAdapter.Update(gridTestDataSet.Emp);
                dataGridView1.Refresh();
                MessageBox.Show("Record Updated");
            }
        }
       

       
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India

A technology enthusiast and software developer by profession. He is developing .Net,database and azure based enterprise applications from past 6 years.


His skills includes C# ,ASP.NET, ASP.NET MVC,WCF,JQuery,Javascript,SQL Server,Oracle . His areas of interests are database development and application software development using Microsoft Technologies.


Visit his blog: queryingsql.com

Blog | Articles | Answers |Facebook
The best anti-virus is a smart user


Comments and Discussions