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; using System.Data.Common; using System.Data.OleDb; namespace WindowsFormsApplication1 { public partial class Form1 : Form { SqlConnection conn; SqlDataAdapter da; DataSet ds; SqlCommandBuilder cmb; public Form1() { InitializeComponent(); SqlConnection conn = new SqlConnection("Data Source=MACHINE;Initial Catalog=JobDetailsDB;Integrated Security=True"); conn.Open(); SqlDataAdapter da = new SqlDataAdapter("Select * FROM JobDetailsDB", conn); DataSet ds = new DataSet(); SqlCommandBuilder cmb = new SqlCommandBuilder(da); dg.DataSource = ds.Tables["JobDetailsTbl"]; } private void Form1_Load(object sender, EventArgs e) { } private void btnUpdate_Click(object sender, EventArgs e) { da.UpdateCommand = cmb.GetUpdateCommand(); da.Update(ds); } } }
da.UpdateCommand = cmb.GetUpdateCommand();