XSD Disconnected Crystal Report DataSource Part 1

An XSD disconnected datasource is a datasource that will execute at run time.  It will use an XML Schema Definition file.  Typically, with SAP Crystal Reports, you create a report with a database connection, a data source and a dataset at design time.  The report can be published with the ability to be executed without dependence on the calling program.

Create Your XSD file

Firstly, create an XSD file that you will use as your Crystal Report DataSource.  The code below will generate an XSD file called “DataSetSchema.xsd”.  Therefore, your report will look for said file every time you need to refresh the fields.  Even though you need the file to refresh fields it is not needed at runtime.using

C#
using System.IO;
...
//Create connection and generate sample dataset
...
//Open your connection
System.Data.SqlClient.SqlConnection tempCN = new System.Data.SqlClient.SqlConnection();

//Open your dataset
System.Data.DataSet tempDS = new System.Data.DataSet();
...

//I like to append 'DS' and 'DT' to identify in the XSD files and Crystal
tempDS.DataSetName = txtPageAppName.Text.Trim() + "DS";
tempTB = tempDS.Tables[0];
tempTB.TableName = txtPageAppName.Text.Trim() + "DT";

//Write XSD                
MemoryStream ms = new MemoryStream();
tempTB.WriteXmlSchema(ms);

//Write XSD File to browser
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=DataSetSchema.xsd");
Response.AddHeader("content-type", "text/plain");
Response.BinaryWrite(ms.ToArray());
Response.End();

XSD Disconnected DataSet

Secondly, open Crystal Reports and select the ADO.NET (XML) in the Database Expert Wizard.

ADO.NET (XML) Data Source
ADO.NET (XML) Data Source #2

Report Layout

Thirdly, lay out the report as you would any report.  In conclusion, as with all disconnected datasets, you will not be able to simply run the report or preview it.  Therefore, you will have to have an application or web page setup to actively view the report.

The sample report below shows a simple Employee listing report in design view.

Report Layout

Without doubt, this is not a method to write reports for managers, but is an excellent option if you need scalability and dynamic reports

Scroll to Top