I have two very similar applications running on the same development
machine. One prints correctly, the other fails with an "Index out of
range" exception.
Here's the code for the one that fails. Believe me, it's exactly
identical except the name of the report and the data in the dataset.
It barfs on the last line:
Dim rpt As CrystalDecisions.CrystalReports.Engine.ReportDocum ent
Dim ds As New DataSet
Dim rptName As String
Dim intEndPageNo As Integer
Dim strCaseMessage As String = " "
Dim mstrMessage As String
Try
rptName = "rptQuery.rpt"
ds = SqlHelper.ExecuteDataset(ConfigSettings.SystemConn ectionString,
CommandType.StoredProcedure, "stpGetQueriesForReport", New
SqlParameter("@CSIDs", LogonUser.CSIDsForReport))
ds.Tables(0).TableName = "stpGetQueriesForReport"
rpt = New CrystalDecisions.CrystalReports.Engine.ReportDocum ent
rpt.Load(LogonUser.CrystalReportPath & rptName)
rpt.SetDataSource(ds)
rpt.PrintOptions.PrinterName = mstrPrinterName
rpt.PrintOptions.PaperOrientation =
CrystalDecisions.[Shared].PaperOrientation.Landscape
rpt.PrintToPrinter(CType(Me.cboNumCopies.SelectedI tem.Value, Integer),
False, 0, 0)
If I replace the last line with literals it STILL barfs:
rpt.PrintToPrinter(1, False, 0, 0)
Anyone have any thoughts? The full error message (as slightly
manipulated by my application to display to the user) is below:
Thanks
Edward
There was a problem in printing. Please contact your system
administrator. Number: CrystalDecisions.CrystalReports.Engine
Message: Index was outside the bounds of the array. Stack Trace: at
CrystalDecisions.CrystalReports.Engine.Migration.P rintOptionsConverter.EROMPaperSourceToDNETPaperSou rce(CrPaperSourceEnum
ePaperSource) at
CrystalDecisions.CrystalReports.Engine.PrintOption s.get_PaperSource()
at
CrystalDecisions.CrystalReports.Engine.PrintOption s.CopyTo(PrinterSettings
printer, PageSettings page) at
CrystalDecisions.CrystalReports.Engine.FormatEngin e.PrintToPrinter(Int32
nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at
CrystalDecisions.CrystalReports.Engine.ReportDocum ent.PrintToPrinter(Int32
nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at
CQDB_WIP.PrinterSelectionForm.PrintQUERYReport() in
c:\inetpub\wwwroot\CQDB_vs2003\forms_misc\PrinterS electionForm.aspx.vb:line
208"