Hi,
I am still trying to figure this one out. What I want to do is update all records in a datagrid when clicking an update button. I have been able to get it to update the current row, but what do I need to do from here to get it to update all records?
Here is my latest code:
SqlConnection updConnection = new SqlConnection(Test_Utility.Properties.Settings.Default.ConnectionString);
string updSqlStmt = "UPDATE Assignment SET Active= '1', StatusType='9999', EndDt =@EndDt WHERE ID=@ID";
try
{
updConnection.Open();
SqlCommand updCmd = new SqlCommand(updSqlStmt, updConnection);
updCmd.Parameters.AddWithValue("@ID", dataGridView1.CurrentRow.Cells["ID"].Value);
updCmd.Parameters.AddWithValue("@EndDt", dataGridView1.CurrentRow.Cells["EndDt"].Value);
updCmd.CommandType = CommandType.Text;
updCmd.ExecuteNonQuery();
txtProgress.Text = "Update completed.";
AssignmentTableAdapter.FillID(ds_Assignment.tAssignment, Convert.ToInt32(txtID.Text));
}
finally
{
updConnection.Close();
updConnection.Dispose();
}