【百分求解】The definition of the report 'Main Report' is invalid(Report Viewer报表问题)

ViewStates 2008-06-13 09:51:23
小弟现在有个报表使用的是REPORTVIEWER控件
大体报表的结构是
主表A,包括2个静态的SUBREPORT B,C,还有一个动态生成的报表D,在D中还有一个SUBREPORT E
现在是A,B,C都能正常显示,但是D显示不出来,然后我就先去掉了E报表
但是最后在DEBUG的OUTPUT中还是出现
An error occurred while executing the subreport ‘subreport3’: The definition of the report 'Main Report' is invalid. (rsErrorExecutingSubreport)

这样的错误,小弟使用的VS2008,错误中的SUBREPORT3就是生成的C报表。

C报表是根据一个自己定义的一个报表模板生成的一个随机文件名的RDLC文件,确认在运行时已经加载了这个C报表,而且最后我直接把生成的文件在VS里查看也能正常显示出报表来。请问下应该怎么办?

报表REPORTVIEWER版本9.0.0.0
...全文
441 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ViewStates 2008-06-26
  • 打赏
  • 举报
回复
我没用水晶报表。。。用的是VS带的REPORTVIEWER
lx_lhy 2008-06-23
  • 打赏
  • 举报
回复
。。。。。。
C#语法:
CrystalReport1 crReportDocument (你的A报表)
ReportDocument crSubreportDocument
nec_5499 2008-06-21
  • 打赏
  • 举报
回复
ViewStates 2008-06-16
  • 打赏
  • 举报
回复
crReportDocument是什么?
看不太懂VB
Jade_2008 2008-06-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 ViewStates 的回复:]
PS:C表生成的方式大部分以网上现有的DynamicTable那种形式对模板报表进行替换
主表A的针对C表的这个SUBREPORT的REPORTNAME使用的是XML方式进行修改成C报表的表名。
[/Quote]
ViewStates 2008-06-13
  • 打赏
  • 举报
回复
PS:C表生成的方式大部分以网上现有的DynamicTable那种形式对模板报表进行替换
主表A的针对C表的这个SUBREPORT的REPORTNAME使用的是XML方式进行修改成C报表的表名。
lx_lhy 2008-06-13
  • 打赏
  • 举报
回复
参考下面的代码,给子报表赋予connection:
'set the crSections object to the current report's sections
crSections = crReportDocument.ReportDefinition.Sections

'loop through all the sections to find all the report objects
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
'loop through all the report objects to find all the subreports
For Each crReportObject In crReportObjects
If crReportObject.Kind = ReportObjectKind.SubreportObject Then
'you will need to typecast the reportobject to a subreport
'object once you find it
crSubreportObject = CType(crReportObject, SubreportObject)

'open the subreport object
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

'set the database and tables objects to work with the subreport
crDatabase = crSubreportDocument.Database
crTables = crDatabase.Tables

'loop through all the tables in the subreport and
'set up the connection info and apply it to the tables
For Each crTable In crTables
With crConnectioninfo
.ServerName = ServerName
.DatabaseName = DatabaseName
.UserID = UserID
.Password = Password
End With
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectioninfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next

End If
Next
Next

4,816

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧