hello,
I have tried to solve this query in button1 i have binded the grid with data and in button 2 i whatever u edit in the grid and hit button2 those records will be saved in the database
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace updategrid
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ds = new DataSet();
}
DataSet ds;
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=phonebook;Integrated Security=True");
con.Open();
SqlDataAdapter adp = new SqlDataAdapter("select * from details", con);
adp.Fill(ds);
DataTable dt = ds.Tables[0];
dataGridView1.DataSource = dt;
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=phonebook;Integrated Security=True");
con.Open();
SqlDataAdapter adp = new SqlDataAdapter("select * from details", con);
SqlCommandBuilder build = new SqlCommandBuilder(adp);
adp.Update(ds.Tables[0]);
con.Close();
}
}
}
Do rate my answer once you find it useful
Thanks & Regards
Radix :)