并感谢您的帮助!我正在尝试在从 Microsoft Reporting Services 中提取报告之前填充 DataTable。
我最初以为我可以运行一个 for 外观(取决于我的“MainTable”中有多少行,并分配每个类别并将其刷新到 Rows.Add 并重复但显然我不能 Row.Add 同名 NewRow。这是到目前为止我所拥有的。感谢您的帮助!:
MyDataSet.ESSRow newESS = MyDataSet.ESS.NewESSRow();
for (int i = 0; i < ds.Tables["MainTable"].Rows.Count; i++)
{
DataRow dRow = ds.Tables["MainTable"].Rows[i];
if(Convert.ToInt32(dRow.ItemArray.GetValue(9).ToString()) > ShiftDelta)//checks if instance is longer than a shift
{
newESS.Station = "7";
newESS.Switch ="7";
newESS.Start = dRow.ItemArray.GetValue(6).ToString();
newESS.Stop = dRow.ItemArray.GetValue(7).ToString();
newESS.SwitchIs = dRow.ItemArray.GetValue(8).ToString();
TimeSpan t = TimeSpan.FromSeconds(Convert.ToInt32(dRow.ItemArray.GetValue(9).ToString()));
newESS.Duration = string.Format("{0:D2}h:{1:D2}m:{2:D2}s", t.Hours, t.Minutes, t.Seconds);
MyDataSet.ESS.Rows.Add(newESS); }
}