Search
Monday, March 2, 2009
Print Crystal Report Programatically with Parameter
Print Report On Click Button Or Programatically with Parameter using Below Code
CrystalReportViewer1_Load
{
'Define Report Document
crReportDocument = New ReportDocument()
'Find Current Printer in Local Machine
Dim printDocument As New System.Drawing.Printing.PrintDocument()
crReportDocument.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName
'find path of report
Path = Application.StartupPath
Path = Mid(Path, 1, Len(Path) - 9)
'load printer
crReportDocument.Load(Path & "\test2.rpt")
'pass Peramter
crReportDocument.SetParameterValue("@invoiceid", invoiceno)
CrystalReportViewer1.ReportSource = crReportDocument
'Assign User name and database name for avoid error Answer
'Incorrect Log on Parameters
crReportDocument.SetDatabaseLogon("sa", "pass#word1", ".\sqlexpress","TATA")
'Print report using Printer
crReportDocument.PrintToPrinter(1, True, 1, 1)
}
End Sub
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment