Dynamically change the XSD file path in Crystal Reports

I have a crystal report based on an XSD schema file.

In the report definition, I can change the location of the data source, in particular the file path. Here I can set the path to the file where the XSD schema file is located on my machine.

At this point, everything is working correctly.

Here is the problem:

If the file path does not exist, the report has a runtime error.

This creates problems, particularly with deployment, as my on-premises development environment is physically different from the test / development environment. that is, the file paths are very different, and I do not want to rely on the hard coding path.

My question is: I would like to know how I can either change this file path dynamically (in code), or set it in the report definition so that it is relative to where the report is?

+6
xsd crystal-reports
source share
2 answers

The easiest way is to set the location of the data source to the same as the location of the report file. When you open the Set Data Source Location dialog box, expand the Properties Plus field, then right-click on the file path name and select Same As Report.

+1
source share

use below code example to install dynamically xml or xsd

ReportDocument crReportDoc.DataSourceConnections[0].SetConnection(p_XMLDocument + " " + tdgDoc_XSD, "", null, ""); // crReportDoc.DataSourceConnections[0].SetConnection(p_XMLDocument + " " + tdgDoc_XSD, "", null, ""); NameValuePairs2 logon = new NameValuePairs2(); logon.Set("QE_ServerDescription", p_XMLDocument + " " + tdgDoc_XSD); logon.Set("Local Schema File", tdgDoc_XSD); logon.Set("Local XML File", p_XMLDocument); crReportDoc.DataSourceConnections[0].SetLogonProperties(logon); 
0
source share

All Articles