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

Data source XSD

Status
Not open for further replies.
Aug 27, 2003
428
US
Hi,

What are the steps to connect to an XSD file as a data source for a new report? I tried ADO.NET but I get a message that "the feature that you are trying to use is on anetwork resource that is unavailable"

Thanks
 
AFAIK, you cannot connect directly to an XSD file from Crystal, you have to connect to a dataset in your Visual Studio project. This is not difficult.

In Visual Studio, your project has to have an instance of a DataSet object. Then you create your report in Crystal in Visual Studio and look for something like "Project Data Sources" (my VS is updating right now, so I can't get into it to tell you the exact wording) as the database to connect to. This will then show you all of the tables that have been pre-defined in the DataSource. NOTE: You can't connect to tables that are defined at runtime - they MUST be predefined in the DataSet in order to be usable by Crystal.

To view the report, I usually put the report viewer in a separate window from the application which allows me to have more than one open at the same time if I need to. I also use the ReportDocument object model to load the report.

The basic process that I use is this:

1. Override the form constructor to include a DataSet as a parameter.
2. In the new constructor, create a typed instance of the report that you're running, use the SetDataSource method of the report to set it to the DataSet passed in to the form, then set the ReportSource of the viewer to the report. In its simplest form, the C# the code looks similar to this:
Code:
public CrystalDocReportViewer(DataSet ds)
{
  InitializeComponent();
  rpt = new CrystalDocReport();
  rpt.SetDataSource(ds);
  viewer.ReportSource = rpt;
}
3. In your main form, pass the DataSet to the viewer form when you create it. This way you're passing in the data set that actually contains the data.


I have sample C# code here:


Look for "Code for CrystalDocumenter application" for the simplest form of this code.

Look for "Code for BOEUserAudit application" for a version of the viewer form that has multiple parameter so that you can tell it which report out of several to run.

-Dell


A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top