[英]There is no row at position 5 show error
I'm Using C Sharp 我正在使用C Sharp
I Get This error after running the debugger to see what is wrong with the code: 运行调试器以查看代码出问题后,我得到此错误:
{"There is no row at position 5."} System.Exception {System.IndexOutOfRangeException}
{“在位置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;
}
}
the problem is here. 问题就在这里。
DataTable dt1 = dt.AsEnumerable().Take(4).CopyToDataTable();
Take(4)
is trying to take 4 rows from table. Take(4)
试图从表中取出4行。 if there are no four rows in table it will give the same error. 如果表中没有四行,它将给出相同的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.