I am trying to print a web based report with Crystal Report using Visual Studio .NET.
I am using the following code for printing:
************************************************** *******************
Dim CR As New CrystalDecisions.CrystalReports.Engine.ReportDocum ent()
Dim temp As String
'The loaction of the report
temp = "C:\Inetpub\wwwroot\PopulateTextFieldCR\CrystalRep ort1.rpt"
CR.Load(temp)
Try
Dim myReportTextObject As CrystalDecisions.CrystalReports.Engine.TextObject
Dim myTestObject As CrystalDecisions.CrystalReports.Engine.ReportObjec t
Dim strDesc As String
'The name of the textfield in CR: DescriptionText
If TypeOf CR.ReportDefinition.ReportObjects.Item("txtDes") Is CrystalDecisions.CrystalReports.Engine.TextObject Then
'The text that you want to show in your textfield
strDesc = "TEST"
CType(CR.ReportDefinition.ReportObjects.Item("txtD es"), CrystalDecisions.CrystalReports.Engine.TextObject) .Text = strDesc
End If
Catch err As Exception
'the description text in the document won't be written
End Try
CR.PrintOptions.PaperOrientation = CrystalDecision[Shared].PaperOrientation.Landscape
CR.PrintOptions.PrinterName = "\\SES-FS01\SES-IADPRT01"
CR.PrintOptions.PaperSize = CrystalDecisions. [Shared].PaperSize.DefaultPaperSize
CR.PrintOptions.PaperSource = CrystalDecisions.[Shared].PaperSource.Auto
CR.PrintToPrinter(1, False, 0, 0)
************************************************** *******************
When I run the project, I get the following error message:
Server Error in '/PopulateTextFieldCR' Application.
--------------------------------------------------------------------------------
Error in File C:\Inetpub\wwwroot\PopulateTextFieldCR\CrystalRepo rt1.rpt: Request cancelled by the user.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalReports.Engine.InternalExc eption: Error in File C:\Inetpub\wwwroot\PopulateTextFieldCR\CrystalRepo rt1.rpt: Request cancelled by the user.
Source Error:
Line 46: CR.PrintOptions.PaperSize = CrystalDecisions.[Shared].PaperSize.DefaultPaperSize
Line 47: CR.PrintOptions.PaperSource = CrystalDecisions.[Shared].PaperSource.Auto
Line 48: CR.PrintToPrinter(1, False, 0, 0)
Line 49:
Line 50: 'CrystalReportViewer1.ReportSource = CR
Source File: C:\Inetpub\wwwroot\PopulateTextFieldCR\WebForm1.as px.
vb Line: 48
Could someone please advice me on how I could fix this error?
Thanks in advance.
Sincerely,
Rino