水晶报表子报表显示问题

zgiw 2011-06-18 08:42:05
我的一个水晶报表中包含一个子报表,可在VB程序每次预览时都提示子报表登录失败,但在水晶报表软件中预览时正常显示,不知道这样如何解决?
...全文
180 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zgiw 2011-09-08
  • 打赏
  • 举报
回复
谢谢,散分
SeeSunSet 2011-08-13
  • 打赏
  • 举报
回复
'显示子报表
Function showSubReport(ByVal mainReport As ReportClass, ByVal Ds As DataSet, ByVal TableName As String, ByVal SubReportControlName As String)
'Dim SubReport As New ReportDocument()
'SubReport = mainReport.OpenSubreport(SubReportName)
Ds.Tables(0).TableName = TableName
'SubReport.SetDataSource(Ds)
'SubReport.Refresh()
Dim subreportName As String
Dim subreportObject As SubreportObject
Dim subreport As New ReportDocument()
If TypeOf (mainReport.ReportDefinition.ReportObjects.Item(SubReportControlName)) Is SubreportObject Then
subreportObject = mainReport.ReportDefinition.ReportObjects.Item(SubReportControlName)
' 获取子报表名称。
SubReportName = SubreportObject.SubreportName
' 打开子报表作为 ReportDocument。
subreport = SubreportObject.OpenSubreport(SubReportName)
' 预览子报表。
subreport.SetDataSource(Ds)
subreport.Refresh()
End If
End Function
zgiw 2011-06-19
  • 打赏
  • 举报
回复
如何解决
zgiw 2011-06-19
  • 打赏
  • 举报
回复
dim oApp as new craxdrt.application
dim oRpt as craxdrt.report
dim orptSub as craxdrt.report
dim rs as adodb.recordset
dim rsSub as adodb.recordset
dim reportname as string

'主表
reportname=app.path & "\mo.rpt"
set rs=m_MO.showMO '读取数据表的一个函数,返回recordset
set orpt=oapp.openreport(reportname,1)
orpt.database.setdatasource rs
orpt.readrecords
'子表
set rssub=m_mo.showMolist
set orptsub=orpt.opensubreport("子表名")
orptsub.database.setdatasource rssub
orptsub.readrecords

水晶报表都是使用pull模式:
在水晶报表中预览正常,就是在程序调用时提示用户登录失败,我之前写过一个系统都没有在代码中为子报表指定过数据源,也能正常使用(win2003+sqlserver2005,windows身份验证,我开发用的电脑与服务器同属一个域),现在的系统(win2008+sqlserver2008),我开发用的电脑与服务器属不同的域,所以会出现子报表登录失败,现在我不知如何操作了?



阿泰 2011-06-19
  • 打赏
  • 举报
回复
应该是子报表没有设置数据源信息

现有代码贴出来看看

4,816

社区成员

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

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