这是我的报告加载功能:但是有一些问题。在 bin 文件夹之前的报告文件然后正确加载。但我想在报告文件夹中分别列出所有报告
Private Function GetDeliveryChallanPrint() As DataTable
Dim data As New DataTable
Using Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("VKDBx").ConnectionString)
Using cmd As New SqlCommand("select * from DcMaster dm Left join DcDetail dd on dm.ID = dd.ID where dm.id = '" & PrinByIDTextBox.Text.ToString() & "'", Conn)
Conn.Open()
Using adp As New SqlDataAdapter
adp.SelectCommand = cmd
adp.Fill(data)
Dim FILEPATH As String = Path.GetDirectoryName(Application.ExecutablePath + "\Reports")
Dim DcPrint As New Rpt_DeliveryChallan
DcPrint.Load(FILEPATH)
DcPrint.SetDataSource(data)
CrystalReportViewer1.ReportSource = DcPrint
CrystalReportViewer1.Refresh()
StatusLabel.Visible = False
Conn.Close()
End Using
End Using
End Using
End Function
在 VB.NET 上加载 Crystal Report 有两种可能性:
使用报告对象:
Dim DcPrint As New Rpt_DeliveryChallan
DcPrint.SetDataSource(data)
CrystalReportViewer1.ReportSource = DcPrint
CrystalReportViewer1.Refresh()
注意:在这种情况下,您需要将报告嵌入到项目中。
使用ReportDocument
并从文件加载报告:
Dim FILEPATH As String = CurDir() & "\Reports\Rpt_DeliveryChallan.rpt"
Dim DcPrint As New ReportDocument
DcPrint.Load(FILEPATH)
DcPrint.SetDataSource(data)
CrystalReportViewer1.ReportSource = DcPrint
CrystalReportViewer1.Refresh()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句