Dim app As New CRAXDRT.Application Dim rpt As New CRAXDRT.Report Dim tbl As CRAXDRT.DatabaseTable Set rpt = app.OpenReport("C:\SOS3000\NewReports\DNOPS01.rpt") rpt.DiscardSavedData For Each tbl In rpt.Database.Tables tbl.ConnectionProperties.DeleteAll tbl.ConnectionProperties.Add "Provider", "MSDASQL" tbl.ConnectionProperties.Add "Data Source", "MS ACCESS DATABASE" tbl.ConnectionProperties.Add "User Id", "Admin" tbl.ConnectionProperties.Add "Password", "1234" tbl.ConnectionProperties.Add "Initial Catalog", "C:\SOS3000\SOS3000S.accdb" Next tbl CRViewer1.ReportSource = rpt rpt.PrintOut False, 1 Set app = Nothing Set rpt = Nothing Set tbl = Nothing
1 Replies - 1947 Views - Last Post: 29 June 2013 - 09:16 PM
Disposing and intializing a crystalreportviewer object in vb6
Posted 25 June 2013 - 12:57 AM
I am using Crystal reports XI and I am using this code to print reports after a transaction. This code works fine but the Problem comes when I attempt a second transaction, I get the error "Method ReportSource of object ICrystalReportViewer11 failed". However If i do a transaction and print the report and close the form after that and then come back into the form to do the second transaction the code works fine. I am convinced that the solution is that I need to "dispose" the reportviewer and "initialise" it when I need to use it but I just need some guidance on how to do this. Any help.
Replies To: Disposing and intializing a crystalreportviewer object in vb6
Page 1 of 1