如何DataColumn
向DataTable
已包含数据的对象添加新的?
伪代码
//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
}
dt.AcceptChanges()
添加新的列和值后,您需要致电吗?