将LocalReport绑定到DataTable - 未发现的错误代码。 [英] Bind LocalReport to DataTable - undiscovered error code.
问题描述
我和许多其他人一样,对使ReportViewer以所需方式运行的复杂性感到恼火。
I, like many others, am annoyed with complexity of getting the ReportViewer to function in a desired manner.
我正在执行存储过程,返回ADO。净数据集,并尝试获取绑定到的报告:
I'm executing a stored procedure, returning an ADO .Net Dataset, and trying to get a report to bind to that:
Dim mySource As 新 ReportDataSource( " MyReportMangler_clsCRData" , Me .BindingSource1) Me .ReportViewer1.LocalReport.DataSources。添加(mySource) Me .ReportViewer1.LocalReport.ReportPath =" xxx"
< font color ="#0000ff"size = 2> Me .BindingSource1.DataSource = thisSet
Dim mySource As New ReportDataSource("MyReportMangler_clsCRData", Me.BindingSource1)Me.ReportViewer1.LocalReport.DataSources.Add(mySource)Me.ReportViewer1.LocalReport.ReportPath = "xxx"
Me.BindingSource1.DataSource = thisSet
我们得到了"一个数据尚未为数据源提供源实例"MyReportMangler_clsCRData"。
当我尝试将BindingSource的数据源设置为ADO.NET DataTable时:
Dim mySource As 新 ReportDataSource( " MyReportMangler_clsCRData" , Me .BindingSource1) Me .ReportViewer1.LocalReport.DataSources.Add(mySource) Me .ReportViewer1.LocalReport.ReportPath =" xxx"
Me .BindingSource1。 DataSource = thisTable
Dim mySource As New ReportDataSource("MyReportMangler_clsCRData", Me.BindingSource1)Me.ReportViewer1.LocalReport.DataSources.Add(mySource)Me.ReportViewer1.LocalReport.ReportPath = "xxx"
Me.BindingSource1.DataSource = thisTable
我们得到:
警告:数据集'WindowsApplication1_PoItems'包含字段'描述'的定义。从数据源返回的结果集中缺少此字段。 (rsMissingFieldInDataSet)
警告:数据集'WindowsApplication1_PoItems'包含字段'描述'的定义。在读取字段期间,数据扩展名返回了错误。位置1的字段没有数据。(rsErrorReadingDataSetField)
当我检查
Dim testSource As BindingSource = CType _ ( Me .ReportViewer1.LocalReport.DataSources(0).Value ,BindingSource)
Dim testTable As DataTable = CType (testSource.DataSource,DataTable)
Dim testSource As BindingSource = CType _(Me.ReportViewer1.LocalReport.DataSources(0).Value, BindingSource)
Dim testTable As DataTable = CType(testSource.DataSource, DataTable)
我发现testTable与thisTable相同。
当然," rsErrorReadingDataSetField"和"rsMissingFieldInDataSet";在任何互联网搜索引擎上返回0匹配。 (或MSDN)
推荐答案
很好。
我没想到DataSet在没有指定BindingSource的情况下工作.DataMember。
I didn't expect a DataSet to work without specifying the BindingSource.DataMember.
至于其他警告:
显然,它不喜欢SQL表中的NULLS。
Aparently, it didn't like NULLS from the SQL tables.
这篇关于将LocalReport绑定到DataTable - 未发现的错误代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!