I am using Crystal Reports 10 and SQL Server 2000.
I have added the following code to a DTS package and is contained within an ActiveX script.
The code seems to work and a report is produced however it does not contain any database values from the tables.
The report has a number of different sub reports.
Set Conn = CreateObject("ADODB.Connection")
Set Comm = CreateObject("ADODB.Command")
Set Rcdset = CreateObject("ADODB.Recordset")
Conn.Open "Provider=SQLOLEDB.1;Initial Catalog=Backup_Database;App=Crystal Export;Data Source=(local)", "blank", "blank"
Comm.ActiveConnection = Conn
'holds the reports that are due to be printed
final = "normal_reports_last_generated"
Rcdset.Open final, Conn, adOpenStatic, , adCmdTable
While (NOT Rcdset.EOF )
currentpractice = Rcdset.Fields.Item(1)
--check and the right number is being added
Set App = CreateObject("CrystalRuntime.application.10") '
Set report = App.OpenReport("j:\REPORT.rpt")
Set DB = report.Database
Set Tables = DB.Tables
Set Table1 = Tables.Item(1)
Should I have more Table1 -- do these relate to sub reports?
report.EnableParameterPrompting = False
report.DiscardSavedData
report.ParameterFields.Item(1).AddCurrentValue (currentpractice)
report.ReadRecords
'Set our export options
report.ExportOptions.DestinationType = crEDTDiskFile
report.PaperOrientation = crPortrait
report.PaperSize = crPaperA4
report.ExportOptions.FormatType = crEFTPortableDocFormat
'report.ExportOptions.FormatType = crEFTWordForWindows
report.ExportOptions.DiskFileName = "C:\Reports\Reports_Generated\report.pdf" ' Path to where to drop PDF.
report.ExportOptions.PDFExportAllPages = True
' Export report without user interaction.
report.Export (False)
I not sure what could be wrong - if someone could point me in the right direction that would be great.
Thanks
I have added the following code to a DTS package and is contained within an ActiveX script.
The code seems to work and a report is produced however it does not contain any database values from the tables.
The report has a number of different sub reports.
Set Conn = CreateObject("ADODB.Connection")
Set Comm = CreateObject("ADODB.Command")
Set Rcdset = CreateObject("ADODB.Recordset")
Conn.Open "Provider=SQLOLEDB.1;Initial Catalog=Backup_Database;App=Crystal Export;Data Source=(local)", "blank", "blank"
Comm.ActiveConnection = Conn
'holds the reports that are due to be printed
final = "normal_reports_last_generated"
Rcdset.Open final, Conn, adOpenStatic, , adCmdTable
While (NOT Rcdset.EOF )
currentpractice = Rcdset.Fields.Item(1)
--check and the right number is being added
Set App = CreateObject("CrystalRuntime.application.10") '
Set report = App.OpenReport("j:\REPORT.rpt")
Set DB = report.Database
Set Tables = DB.Tables
Set Table1 = Tables.Item(1)
Should I have more Table1 -- do these relate to sub reports?
report.EnableParameterPrompting = False
report.DiscardSavedData
report.ParameterFields.Item(1).AddCurrentValue (currentpractice)
report.ReadRecords
'Set our export options
report.ExportOptions.DestinationType = crEDTDiskFile
report.PaperOrientation = crPortrait
report.PaperSize = crPaperA4
report.ExportOptions.FormatType = crEFTPortableDocFormat
'report.ExportOptions.FormatType = crEFTWordForWindows
report.ExportOptions.DiskFileName = "C:\Reports\Reports_Generated\report.pdf" ' Path to where to drop PDF.
report.ExportOptions.PDFExportAllPages = True
' Export report without user interaction.
report.Export (False)
I not sure what could be wrong - if someone could point me in the right direction that would be great.
Thanks