Skip to Content
Former Member
Jul 17, 2008 at 01:26 PM

error setting datasource


I'm using Visual Studio 2008 and Crystal Reports X. I have a report with two subreports. I'm able to set the datasource for the main report and the first subreport, but the second subreport always fails. I've tried reversing the order of the subreports to see if there was a problem with a specific subreport, but regardless of which one I load first, the first always loads and the second doesn't. Here's part of the error message generated from our log file followed by an example of the code.

The error:

Message: The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))


at CRAXDRT.DatabaseClass.SetDataSource(Object data, Object dataTag, Object tableNumber)

The code:

Dim app As New CRAXDRT.Application

Dim rpt As CRAXDRT.Report

Dim ds As New DataSet

Dim tblName As String = ""

Dim reportFile As String = ""

Try some stuff to prepare the data

reportFile = ...some function that gets the report file name

rpt = app.OpenReport(reportFile, 1)

With rpt

If si.ReportFormat.ToUpper = "A4" Then

.PaperSize = CRAXDRT.CRPaperSize.crPaperA4


.PaperSize = CRAXDRT.CRPaperSize.crPaperLetter

End If

.EnableParameterPrompting = False

.RecordSelectionFormula = ChartFilter(chart, sessionID)


End With

tblName = rpt.Database.Tables(1).Name

PopulateChartDataset(ds, si.Treaty, tblName, sessionID)

rpt.Database.SetDataSource(ds.Tables(tblName), 3)

'set the subreport data

Dim subRpts() As String = {"chartv-dssub.rpt", "chartv-poesub.rpt"}

For Each subRpt As String In subRpts

Dim sRpt As CRAXDRT.Report

sRpt = rpt.OpenSubreport(subRpt)

tblName = sRpt.Database.Tables(1).Name

PopulateChartDataset(ds, si.Treaty, tblName, sessionID)

sRpt.Database.SetDataSource(ds.Tables(tblName), 3)

sRpt = nothing


This is similar to what we have done in VS 2003, but have sent a recordset object. It works there.

The Crystal dll referenced as a com object. The version is These reports were developed in Crystal Reports, not the Visual Studio IDE. We have a number of reports, and if there are no subreports they generate as expected, as long as only one report is returned. Oddly enough, when multiple reports are returned I will occasionally get the same error. Those reports are generated sequentially so again there are multiple calls to set the datasource (using different report objects and data tables). Does anyone have any ideas what this error means or where I might look?