[英]There is no row at position 5 show error
我正在使用C Sharp
運行調試器以查看代碼出問題后,我得到此錯誤:
{“在位置5沒有行。”} System.Exception {System.IndexOutOfRangeException}
dt = new DataTable();
dt = objReport.USERWISEACCOUNTINGINFORMATIONWITHINBOUNDOUTBOUND(strDomainName, 0, fromDate, toDate);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
DataTable dt1 = dt.AsEnumerable().Take(4).CopyToDataTable();
int[] YPointMember = new int[dt1.Rows.Count];
DateTime[] XPointMember = new DateTime[dt1.Rows.Count];
for (int count = 0; count < dt1.Rows.Count; count++)
{
YPointMember[count] = Convert.ToInt32(dt1.Rows[count]["INBOUND"]);
XPointMember[count] = Convert.ToDateTime(dt1.Rows[count]["connectdatetime"]);
}
Chart1.Series[0].Points.DataBindXY(YPointMember, XPointMember);
Chart1.Series[0].BorderWidth = 1;
Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:HH";
Chart1.ChartAreas[0].AxisY.LabelStyle.Format = "h : h";
Chart1.ChartAreas[0].AxisY.Interval = 2;
Chart1.ChartAreas[0].AxisY.IntervalType = DateTimeIntervalType.Hours;
Chart1.ChartAreas[0].AxisY.IntervalOffset = 0;
}
}
問題就在這里。
DataTable dt1 = dt.AsEnumerable().Take(4).CopyToDataTable();
Take(4)
試圖從表中取出4行。 如果表中沒有四行,它將給出相同的錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.