加载报告失败错误显示直接打印水晶报告vb.net(非每次)Pin

时间:2017-12-21 20:44:42

标签: c# vb.net crystal-reports

我正在使用此代码打印没有预览的水晶报表。有时会出现“加载报告失败”错误。当我关闭并重新打开应用程序时,将打印报告。如何在不重新启动应用程序的情况下解决此错误?

我的代码:

Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
''  Dim CrTable As Table
Dim TableCounter
Dim crReportDocument As New ReportDocument
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
Dim billno As New InfoGeneration
Dim sname As ConfigurationSettings
crReportDocument.Load(Application.StartupPath & "\Reports\rptsinv.rpt")
With crConnectionInfo
    .ServerName = sname.AppSettings("servername")
    .DatabaseName = sname.AppSettings("dbname")
    .UserID = sname.AppSettings("username")
    .Password = sname.AppSettings("password")
End With
CrTables = crReportDocument.Database.Tables
For Each CrTable In CrTables
    crtableLogoninfo = CrTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo = crConnectionInfo
    CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next

crParameterFieldDefinitions = crReportDocument.DataDefinition.ParameterFields
crParameterFieldLocation = crParameterFieldDefinitions.Item("s_id")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = txts_id.Text
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
crReportDocument.PrintToPrinter(txtcopies.Text, False, 0, 0)

0 个答案:

没有答案