I need to update database after adding/changing column in DataColumnCollection in DataTable. How can I do this?
I used this code to add new column:
dataTable.Columns.Add("newColumn", typeof (int));
This code works for changed rows in dataTable, but not for changed Columns (it does nothing).
SqlDataAdapter adapter = new SqlDataAdapter(cmdText, _connection);
SqlCommandBuilder cb = new SqlCommandBuilder(adapter);
adapter.Update(dataTable);
In cmdText is select command used to get dataTable.
So it looks like there is no way to do this using dataTable. You have to use SQL command (ALTER TABLE ...).