alexking
asked on
Failed to load report error using crystal reports and vb.net
I am using a crystal reports that ships with visual studio.net to create customer accounts and after printing 67 reports to disc it is blowing out with "Load Report Failed" on the line cryRpt.Load(strReportName)
I think perhaps I am not closing something or disposing of something, the code I am using is attached - I loop over my customer set (of about 300) and call this routine every time. My report is linked to a table in sql server 2005.
I think perhaps I am not closing something or disposing of something, the code I am using is attached - I loop over my customer set (of about 300) and call this routine every time. My report is linked to a table in sql server 2005.
Private Sub ConfigureInvoiceAccRunRpt()
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim strReportName As String = ""
Try
myConnectionInfo.AllowCustomConnection = True
myConnectionInfo.DatabaseName = "MyDb"
myConnectionInfo.ServerName = MyServerName
myConnectionInfo.IntegratedSecurity = True
myConnectionInfo.Type = ConnectionInfoType.SQL
strReportName = "C:\Invoice.rpt"
Dim cryRpt As New ReportDocument
cryRpt.Load(strReportName) '<-- fails here after 67 times
SetDBLogonForReport(myConnectionInfo, cryRpt)
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue
crParameterValues.Clear()
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields
crParameterDiscreteValue.Value = 3
crParameterFieldDefinition = crParameterFieldDefinitions.Item("SiteID")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.CrystalReport, "C:\Spool\Accounts\Customername.rpt")
Catch
MsgBox(Err.Description)
Finally
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER