PDA

Click to See Complete Forum and Search --> : How to populate my sub report w/ data vb.net 2005


o9z1
Jan 31st, 2008, 03:03 PM
I have created a main report and a sub report, which both work fine by themselves. When I insert the 2nd report as a sub report, the main report still contains data, but the sub report is blank. I think the problem is with my code. Could anyone evaluate my code or provide a link to an example of how to do this. This is my first shot at sub reports.


Dim strReportPath1 As String = "PCMarketException"
Dim strConnection As String = "Data Source=HERCULES;Initial Catalog=Carcass2;Integrated Security=True"
Dim Connection As New SqlConnection(strConnection)
Dim strSQL As String = "VERY VERY LONG SQL Statement(I won't list all of this out)"
Dim strSQL1 As String = "SELECT * FROM t_groupdata"
Dim DA As New SqlDataAdapter(strSQL, Connection)
Dim DA1 As New SqlDataAdapter(strSQL1, Connection)
Dim DS As New DataSet
Dim DS1 As New DataSet

DA.Fill(DS, "PCMarket")
DA1.Fill(DS1, "CarcassData")
Dim dt As DataTable
dt = DS.Tables("PCMarket")
Dim dt2 As DataTable
dt2 = DS1.Tables("CarcassData")
Dim strReportPath As String = Application.StartupPath & "\" & strReportPath1 & ".rpt"

If Not IO.File.Exists(strReportPath) Then
'Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))
strReportPath = Application.StartupPath & "\..\..\" & strReportPath1 & ".rpt"
End If

Dim cr As New PCMarketException
cr.Load(strReportPath)
cr.SetDataSource("PCMarket")
cr.Subreports.Item("CarcassData").SetDataSource(DS1)

cvwPCMarket.ShowRefreshButton = False
cvwPCMarket.ShowCloseButton = False
cvwPCMarket.ShowGroupTreeButton = False
cvwPCMarket.ReportSource = cr

o9z1
Feb 4th, 2008, 01:52 AM
anyone?