Last post Dec 27, 2009 09:40 PM by Song-Tian - MSFT
Dec 25, 2009 12:01 PM|gdpwork|LINK
Hi, I'm developing a solution with an architecture like thisPresentationService LayerBusiness LayerData LayerDatabaseThey communicate each other with DTOs.My problem becomes when I want to create reports, I don't used .xsd nor .xss files, and I don't know if I should use Crystal Report or Report Viewer. When I go to tutorials I see all of them using .xsd and .xss and I don't want, or at least I don't see it worth enough to do it just for the reports...How can I create the report using the output of my Service Layer (IEnumerable's)? What's the best approach here Crystal Reports or Report Viewer?Thanks in advance! Daniel.
Dec 27, 2009 09:40 PM|Song-Tian - MSFT|LINK
You can add reports to your application using the version of Crystal Reports that comes with VS.NET. Right click your project in
Solution Explorer and select Add | Add New Item | Crystal Reports.
The DataSource for your report can be based on an XML Schema (XSD) file. Schemas files are XML files that describe the columns in your datatable. (To see how to set the DataSource to a .NET DLL
click here). The easiest way to create a schema for your data is to call your dataset's
Dim strConnection As String = "..."
Dim Connection As New OleDbConnection(strConnection)
Dim DS As New DataSet
Dim strSQL As String = "Select * From Customers"
Dim DA As New OleDbDataAdapter(strSQL, Connection)
strSQL = "Select * From Orders"
DA = New OleDbDataAdapter(strSQL, Connection)
To add the schema to your solution right click your project in Solution Explorer and select
Add | Add Existing Item and navigate to your .XSD file.
In your Crystal Report you reference the schema by opening the Field Explorer, right clicking
Database Fields, selecting Database Expert, expanding the Create New Connection node, and the
ADO.NET (XML) node then double clicking Make New Connection. At the
ADO.NET (XML) dialog set the File Path to your XSD file by clicking the elipses and navigating to the schema file. Hit
Finish when done.
Your schema will appear under the ADO.NET (XML) node in the Available Data Sources pane. Select the desired datatable within it and add it to the
Selected Tables pane. Hit OK when done.
Now in the Field Explorer under the Database Fields node you will see your datatable and its fields which you can drag onto the report.