|
-
Jan 31st, 2008, 04:03 PM
#1
Thread Starter
Addicted Member
How to populate my sub report w/ data vb.net 2005
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.
Code:
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
-
Feb 4th, 2008, 02:52 AM
#2
Thread Starter
Addicted Member
Re: How to populate my sub report w/ data vb.net 2005
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|