How do I add a new DataColumn
to a DataTable
object that already contains data?
PseudoCode
//call SQL helper class to get initial data
DataTable dt = sql.ExecuteDataTable("sp_MyProc");
dt.Columns.Add("NewColumn", type(System.Int32));
foreach(DataRow row in dr.Rows)
{
//need to set value to NewColumn column
}
Only you want to set default value parameter. This calling third overloading method.
Should it not be
foreach
instead of for!?Here is an alternate solution to reduce For/ForEach looping, this would reduce looping time and updates quickly :)
Just keep going with your code - you're on the right track:
Try this