void databaseUpdate()
conString = "Data Source=(local);Initial Catalog=Northwind;Integrated Security=True";
            con = new SqlConnection(conString);
            string quryString = " select * from Employees";
            da = new SqlDataAdapter(quryString, con);
            ds = new DataSet();
            da.Fill(ds, "Emp");
            //dataGridView1.DataSource = ds.Tables["Emp"];
            dataGridView1.Columns.Add("EmpID", "ID");
            dataGridView1.Columns.Add("FirstName", "FirstName");
            dataGridView1.Columns.Add("LastName", "LastName");
            int row = ds.Tables["Emp"].Rows.Count - 1;
            for (int r = 0; r<= row; r++)
                dataGridView1.Rows[r].Cells[0].Value = ds.Tables["Emp"].Rows[r].ItemArray[0];
                dataGridView1.Rows[r].Cells[1].Value = ds.Tables["Emp"].Rows[r].ItemArray[1];
                dataGridView1.Rows[r].Cells[2].Value = ds.Tables["Emp"].Rows[r].ItemArray[2];


adapting the above, how would you update it???

Update what? You mean dgv?

1st of all, you have to put the gdv creation into a seperate method, which has to be called only ones. Another method will populate the dgv - this method can be called numerous times. And you can use DataSource to populate dgv, no need to populate it "manually" in the runtime (like for loop in the upper example).

By update, I mean any changes made to the datagridview are transfered to the database at the click of the update button event.
I have tried:

da.Update(ds, "Emp");

within a button event.

I have populated the datagridview manually as some columns are check boxes.

This article has been dead for over six months. Start a new discussion instead.