ReportViewer,索引超出数组(RDLC报表)C#的范围

本文关键字:报表 范围 RDLC 索引 数组 ReportViewer | 更新日期: 2023-09-27 18:20:14

我正在尝试生成一个rdlc报告,而现在dataSet正在抛出一个异常。即"索引超出了数组的界限。"

在命令视图中,我在命令窗口中得到以下错误。

>? dataTable.GetErrors()[0]
   'dataTable.GetErrors()[0]' threw an exception of type 
   'System.IndexOutOfRangeException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233080
HelpLink: null
IPForWatsonBuckets: {0}
InnerException: null
IsTransient: false
Message: "Index was outside the bounds of the array."
RemoteStackTrace: null
Source: null
StackTrace: null
TargetSite: null
WatsonBuckets: null
_HResult: -2146233080
_className: null
_data: {System.Collections.ListDictionaryInternal}
_dynamicMethods: null
_exceptionMethod: null
_exceptionMethodString: null
_helpURL: null
_innerException: null
_ipForWatsonBuckets: {0}
_message: "Index was outside the bounds of the array."
_remoteStackIndex: 0
_remoteStackTraceString: null
_safeSerializationManager: {System.Runtime.Serialization.SafeSerializationManager}
_source: null
_stackTrace: null
_stackTraceString: null
_watsonBuckets: null
_xcode: -532462766
_xptrs: {0}

在历史调试中,它指向这些代码

public virtual int Fill(ReportDataSet.DataTable1DataTable dataTable)
{
    this.Adapter.SelectCommand = this.CommandCollection[0];
    if ((this.ClearBeforeFill == true))
    {
        dataTable.Clear();
    }
    int returnValue = Adapter.Fill(dataTable);
    return returnValue;
}

报表查看器保持空白。有什么建议吗?

ReportViewer,索引超出数组(RDLC报表)C#的范围

因为DataTable可以存储的最大行数是16777216。因此,如果您的结果超过了此记录,您将得到"Index was outside of the array"错误。

实际上,这个错误是合法的。这是我的错。特定列只属于特定类型的客户。然而,我提取了所有记录,因此长度被声明为例如3,但由于该列,它过去变成了4,

不管怎样,我生成了两个报告,现在一切都很好。谢谢各位,

避免RDLC报告文件中的表达式