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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report from multiple Datasets (VB.NET)

Status
Not open for further replies.

DBNECWaters

Programmer
Mar 9, 2005
6
US
I am writing code in VB.NET with CR XI and I am trying to populate the reports from datasets. My brickwall that I am hitting is, how to assign multiple sources for one report.

Here's the scenario. I have a report that lists customer orders which works great. and I have a dataset that stores the Customers name, address, etc.. and I want to add that to the top of the report, but I am not sure how to add the 2nd dataset as a report source for the same report.

any help would be Greatly Appreciated
 
You'd need to state how you're currently populating the report, but the short answer is to use a Union All type of statement.

Another approach might be to create another report with the new info and use it as a subreport in the report header of the current report.

-k
 
currently, I am populating the report by storing the results of a query in a Typed dataset. Then I set the report source equal to the dataset and call the RefreshReport() function so that it updates.

I have the report setup where it should work, I just can't figure out how to set the other dataset as a report source since the function only takes 1 parameter. (VB code)

I'm not familiar with the Union All statement, unless you are talking about the union statement in SQL.
 
You will need a sub-report to display the orders list. Each report or sub-report can only handle one DataTable from a DataSet at a time. Use the main report to deal with the customer records and the sub-report for the orders belonging to the customer.

If you have the dataset already filled with 2 datatables in a hierarchy eg: 1 customer and many orders then set this to the main report's datasource and also to the subreport's datasource. There is no need to add any linking for the sub-report as the dataset should already be filtered unless you intend to print multple customer and their orders in one go.

The alternative, which is only feasible if you are directly accessing the database, is to 'flatten' the the data using a query, or on a SQL Server using a view, which has the query. This joins the tables together with the orders with the customer details repeating on each line. Then use a grouping band in the report by customer so you can add a header for the customer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top