Ok, so I almost finished writing a huge post for you but right before I finished I closed the window by accident instead of minimizing it. So I'm sorry but I'm not spending another half hour to write that today(as you said its monday). Here is my abbreviated post: Here is the configure crystal reports routine that I call from page_load. Check out my post http://forums.asp.net/t/1127676.aspx to understand this a little better if you don't already.
Private Sub ConfigureCrystalReports()
If (Session("supplierRpt") Is Nothing) Then
supplierRpt = New ReportDocument()
supplierRpt.Load(Server.MapPath("SupplierReport_Final.rpt"))
' supplierRpt.Load(Server.MapPath("SupplierReport_Final_bak.rpt"))
LoadDataSources()
supplierRpt.SetDataSource(dsOcc)
supplierRpt.Subreports("FailOcc").SetDataSource(dsOcc.Tables("FailOcc"))
supplierRpt.Subreports("IndexByFailure").SetDataSource(dsOcc.Tables("IndexFail"))
supplierRpt.Subreports("FailByRank").SetDataSource(dsOcc.Tables("IndexFail"))
supplierRpt.Subreports("FailureType").SetDataSource(dsOcc.Tables("FailureType"))
supplierRpt.Subreports("ResponseTime").SetDataSource(dsOcc.Tables("ResponseSummary"))
supplierRpt.Subreports("ResponseSummary").SetDataSource(dsOcc.Tables("ResponseSum"))
supplierRpt.Subreports("JPN_ResponseSummary").SetDataSource(dsOcc.Tables("ResponseSum"))
SetParameters() ‘ Sets the parameters in a ‘System.Collections.Specialized.StringDictionary object
‘Pushes parameters down through report to subreports
‘note: keep parameter names the same for subreports
ApplyParams()
Session("supplierRpt") = supplierRpt
Else
supplierRpt = CType(Session("supplierRpt"), ReportDocument)
End If
Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
'setup db connection for report
myConnectionInfo.DatabaseName = ""
myConnectionInfo.UserID = ...
myConnectionInfo.Password = ...
myConnectionInfo.ServerName = ...
SetDBLogonForReport(myConnectionInfo)
crv.ReportSource = supplierRpt
End Sub
Then inside of LoadDataSources() I first load the main report data(parameters used in main report and subreports) then I call each individual subreport load to load each query into a table in my dataset dsOCC. Here is the code for one of the simpler queries(method is exact same for more complex ones): This table, Failure Type loads a pie chart that shows percentages of different failure types. But very similar idea for other types of graphs. So the graph itself would have as data On Change Of: FailureType.basicfailurecode, Show Values: Percentage of Sum of FailureType.Cnt
Private Sub LoadFailureType()
Dim conn As String = connstring
Dim sqlFailureType As String = _
"SELECT supplier,supplierloc,COUNT (occdate) cnt, basicfailurecode " & _
"FROM VW_QAOCC_REPORTCARD " & _
"WHERE supplier IN (" & rptSupplier & ") and supplierloc in (" & rptSupplierLoc & ") " & _
"AND occdate BETWEEN TO_DATE('" & rptBegDate.ToString("d") & "','MM/dd/yyyy') and TO_DATE('" & rptEndDate.ToString("d") & "','MM/dd/yyyy') " & _
"and (upper(trim(foundby)) not like '%MARKET%' or foundby is null) " & _
"and (upper(trim(foundby)) not like '%TRIAL%' or foundby is null) " & _
"and (upper(trim(rank)) not like '%MARKET%' or rank is null) " & _
"and (upper(trim(rank)) not like '%TRIAL%' or rank is null) " & _
"and nvl(void,'N') = 'N' " & _
"GROUP BY supplier,supplierloc,basicfailurecode"
Dim rptFailureTypeAdapter As OleDb.OleDbDataAdapter = _
New OleDbDataAdapter(sqlFailureType, conn)
‘ First time the query is run it should create XML schema to use as Ado datasource in Crystal Reports so that data doesn't have to be there at CR design time, just column names
‘Create XML schema to use in setting dataset in report designer,
Comment out after xml is created
'dsFailureType.WriteXmlSchema("c:\temp\failuretype.xml")
‘once xml is created then just fill the datatable as normal
rptFailureTypeAdapter.Fill(dsOcc, "FailureType")
End Sub
Then in the graphs just make sure you set the subreport db-links to point to the correct parameters.
Its not a super easy process but once you get the hang of it its not too hard. If you have questions I will try to answer to my best ability. Good luck.
Eric