I am working on a VB 2005 project, that needs to call a Crystal Report, and pass it two parameters, then be able to set the printer settings and print the report, all without the report viewer control.
If anyone has and sample code for this, I would appreciate it!
There are 2 different architectures you can use. I generally use the approach where the reports are free-standing rpt files, so this will be the example I will describe.
We retrieve the desired data to be displayed into a dataset, initialize a ReportDocument class, and pass it the path of the rpt file, the dataset, and the parameters. Be sure that when you define the report that you set the datasource to a strongly typed dataset you have already created. If you are letting Crystal pull the data directly from the db, then you don't need to worry about the strongly typed dataset.
If you want the reports compiled into the app, then you won't want to use this approach.
'1. Take care of the data aggregation and passing to report...or allow Crystal to pull it
'2. Instantiate the report engine Dim CrystalReport as new CrystalDecisions.CrystalReports.Engine
'3. Tell the ReportDocument what rpt file to use Me.CrystalReport.Load("ReportPath", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy)
'4. Set the parameter values CrystalReport.SetParameterValue("theValue", TheParameterName)
'5. Print directly to the printer CrystalReport.PrintToPrinter(1, False, 0, 0)
Joe
Copyright (c) 2008 GSP Developers Walling Info Systems | Terms Of Use | Privacy Statement