I have four coloum tables in an SQL database. Information for the first three columns is provided by another source. Coloum 4 is set to null by default.
Then I get a win form with data that is populated with information from the sql database using the following code:
public DataTable populateFormList()
{
SqlConnection con = new SqlConnection(Properties.Settings.Default.sqlConnectionString);
SqlCommand cmd = new SqlCommand("SELECT * FROM of_formlist_raw", con);
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
return dt;
}
datagridview2.DataSource = populateFormList();
datagridview2.Refresh();
Now this works great when getting my data.
The user can then make changes to the null values in column 4.
How can I easily write these changes from the datatable back to the SQL table?
In other words, once there are additional values on the datatable screen, how can I then save the updated information back to the SQL data from which it was originally obtained?
Thank.
source
share