Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all articles
Browse latest Browse all 3938

How to create a Join, or place a datatable within a datatable for ReportViewer

$
0
0
I have this report to write, it's content is company information and then sales numbers for months for 5 years below the company information

eg.
ABC Company John 714-555-1212 ATD: $1.00 Balance: $0.00

Year Jan Feb March
2016 $1.00 $2.00 $3.00
2015 $2.00 $1.00 $5.00
2014 $3.00 $2.00 $1.00

So I'm using Dataset and DataTable to build the data
I created 2 tables
Dim rs_CR As DataTable = New DataTable()
rs_CR.TableName = "dt_customerRecords" 
rs_CR.Columns.Add(New DataColumn("ID", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("Name", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("FName", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("LName", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("Phone", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("Fax", System.Type.GetType("System.String")))
rs_CR.Columns.Add(New DataColumn("ATD", System.Type.GetType("System.Decimal")))
rs_CR.Columns.Add(New DataColumn("Balance", System.Type.GetType("System.Decimal")))
I want to add another something here to join the table below. In the RDLC using a Tablix, I can only have 1 dataset. If I create 2 datasets, the dataset prints after the data above, and is not part of the set above.
Dim rs_RP As DataTable = New DataTable()
rs_RP.TableName = "dt_reportData" 
rs_RP.Columns.Add(New DataColumn("Year", System.Type.GetType("System.Int32")))
rs_RP.Columns.Add(New DataColumn("P1", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P2", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P3", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P4", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P5", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P6", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P7", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P8", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P9", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P10", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P11", System.Type.GetType("System.Decimal")))
rs_RP.Columns.Add(New DataColumn("P12", System.Type.GetType("System.Decimal")))

//Assign the dataSet to the Tablix in the report canvas body
Dim ds_CR As DataSet = New DataSet()
ds_CR.DataSetName = "ds_customerRecords"
ds_CR.Tables.Clear()
ds_CR.Tables.Add(rs_CR)
ds_CR.Tables(0).TableName = "tablix_customerRecords" 
//Write the datasource to the report canvas
rv_Canvas.LocalReport.DataSources.Clear()
rv_Canvas.LocalReport.DataSources.Add(New ReportDataSource("ds_customerRecords", ds_CR.Tables(0)))
rv_Canvas.LocalReport.Refresh()

As a caveat, I'm getting the data from an old Foxpro database that is not quite SQL

Viewing all articles
Browse latest Browse all 3938


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>