Create a Crystal Report based on an XML schema (XSD) file
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 WriteXmlSchema method:
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.
To learn how to run the Crystal report and display it in the CrystalReportViewer
control visit my Crystal Report Viewer