Crystal 报表 vb.net 使用没有关系的子报表 table
Crystal Report vb.net using subreport without relation table
我在 crystal 报告中使用了 2 个子报告。这两个报告都没有任何 link 或相互关联。但与证据.
的主要报告有关
我的代码:
dim mReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
dim querymain, query1, query2 As String
mReport = New CrystalReport1
querymain = "SELECT * from tblmain where evidence = '" & EvD & "'"
Call DataSourceConnection_Report() 'my setconnection and setlogon
mReport.Database.Tables(0).SetDataSource(ExecuteSQLQuery(querymain))
query1 = "SELECT * FROM tbl1 WHERE EVIDENCE = '" & EvD & "'"
mReport.Subreports("sub2").SetDataSource(ExecuteSQLQuery(query1))
query2 = "SELECT * FROM tbl2 WHERE EVIDENCE = '" & EvD & "'"
mReport.Subreports("sub3").SetDataSource(ExecuteSQLQuery(query2))
CrystalReportViewer1.Refresh()
CrystalReportViewer1.ReportSource = mReport
但它只会显示我的主报告数据,而将我的子报告留空。
如何填写我的子报告?
您应该像这样实例化您的子报表:
mReport As New CrystalReport1
querymain = "SELECT * from tblmain where evidence = '" & EvD & "'"
Call DataSourceConnection_Report()
mReport.Database.Tables(0).SetDataSource(ExecuteSQLQuery(querymain))
Dim sub2 As CrystalDecisions.CrystalReports.Engine.ReportDocument
sub2 = mReport.OpenSubreport("sub2")
sub2.SetDataSource(ExecuteSQLQuery(query1))
Dim sub3 As CrystalDecisions.CrystalReports.Engine.ReportDocument
sub3 = mReport.OpenSubreport("sub3")
sub3.SetDataSource(ExecuteSQLQuery(query2))
我在 crystal 报告中使用了 2 个子报告。这两个报告都没有任何 link 或相互关联。但与证据.
的主要报告有关我的代码:
dim mReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
dim querymain, query1, query2 As String
mReport = New CrystalReport1
querymain = "SELECT * from tblmain where evidence = '" & EvD & "'"
Call DataSourceConnection_Report() 'my setconnection and setlogon
mReport.Database.Tables(0).SetDataSource(ExecuteSQLQuery(querymain))
query1 = "SELECT * FROM tbl1 WHERE EVIDENCE = '" & EvD & "'"
mReport.Subreports("sub2").SetDataSource(ExecuteSQLQuery(query1))
query2 = "SELECT * FROM tbl2 WHERE EVIDENCE = '" & EvD & "'"
mReport.Subreports("sub3").SetDataSource(ExecuteSQLQuery(query2))
CrystalReportViewer1.Refresh()
CrystalReportViewer1.ReportSource = mReport
但它只会显示我的主报告数据,而将我的子报告留空。
如何填写我的子报告?
您应该像这样实例化您的子报表:
mReport As New CrystalReport1
querymain = "SELECT * from tblmain where evidence = '" & EvD & "'"
Call DataSourceConnection_Report()
mReport.Database.Tables(0).SetDataSource(ExecuteSQLQuery(querymain))
Dim sub2 As CrystalDecisions.CrystalReports.Engine.ReportDocument
sub2 = mReport.OpenSubreport("sub2")
sub2.SetDataSource(ExecuteSQLQuery(query1))
Dim sub3 As CrystalDecisions.CrystalReports.Engine.ReportDocument
sub3 = mReport.OpenSubreport("sub3")
sub3.SetDataSource(ExecuteSQLQuery(query2))