Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Datasource in Subreport [.NET]

Status
Not open for further replies.

RobHudson

Programmer
Apr 30, 2001
172
GB
Hello!

Does anybody know the correct way to change the datasource of a subreport at runtime using .NET [ASP.NET specifically - if that makes any difference]??

I have included the code I am using at the moment but this doesn't seem to do the biz :(
When designing the report, I made the datasource the result of a stored procedure and passed through specific criteria. It appears that if I don't use the same criteria at runtime - it just breaks!! [Get a prerender error]

The code:
Code:
'Set main report
crReportMain = New LabReport()

'Prepare data
dsMain = _wsSample.SelectFromSampleMain(Request.QueryString("id"), _sUser, _sPass)

'Change datasource
crReportMain.SetDataSource(dsMain)

'Set up the subreports ready
crReportMain.OpenSubreport(CType(crReportMain.ReportDefinition.ReportObjects.Item("srptMetalAnalysis"), CrystalDecisions.CrystalReports.Engine.SubreportObject).SubreportName).SetDataSource(_wsSample.getElementsAsCrossTab(Request.QueryString("id"), _sUser, _sPass))
crReportMain.OpenSubreport(CType(crReportMain.ReportDefinition.ReportObjects.Item("srptAnalysis"), CrystalDecisions.CrystalReports.Engine.SubreportObject).SubreportName).SetDataSource(_wsSample.SelectAllTestResults(Request.QueryString("id"), _sUser, _sPass))

'Show the outcome of the report on screen
'Assign report to viewer
With crViewer
      .ReportSource = crReportMain
      .Visible = True
End With

Any help would be ace :D
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top