PrintToPrinter fails - Index out of range

T

teddysnips

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.ReportDocument
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.SystemConnectionString,
CommandType.StoredProcedure, "stpGetQueriesForReport", New
SqlParameter("@CSIDs", LogonUser.CSIDsForReport))
ds.Tables(0).TableName = "stpGetQueriesForReport"

rpt = New CrystalDecisions.CrystalReports.Engine.ReportDocument

rpt.Load(LogonUser.CrystalReportPath & rptName)

rpt.SetDataSource(ds)

rpt.PrintOptions.PrinterName = mstrPrinterName

rpt.PrintOptions.PaperOrientation =
CrystalDecisions.[Shared].PaperOrientation.Landscape

rpt.PrintToPrinter(CType(Me.cboNumCopies.SelectedItem.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.PrintOptionsConverter.EROMPaperSourceToDNETPaperSource(CrPaperSourceEnum
ePaperSource) at
CrystalDecisions.CrystalReports.Engine.PrintOptions.get_PaperSource()
at
CrystalDecisions.CrystalReports.Engine.PrintOptions.CopyTo(PrinterSettings
printer, PageSettings page) at
CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32
nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at
CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32
nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at
CQDB_WIP.PrinterSelectionForm.PrintQUERYReport() in
c:\inetpub\wwwroot\CQDB_vs2003\forms_misc\PrinterSelectionForm.aspx.vb:line
208"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top