Question: I have a crystal report that is based on an XSD schema file.

Within the report definition, I can modify the datasource location, specifically, the file path. This is where I can set the file path to where the XSD schema file resides on my machine.

At this point, everything works correctly.

Here is the problem:

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

This poses issues, specifically, with deployment since my local development environment is physically different from the testing/live environment. i.e. File paths are very different and I don't want to rely on a 'hard-coded' file path.

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

Answer: 
The easiest way would be to set the datasource location to be the same as the report file location. When you open up the Set Datasource Location dialog, expand the Properties plus-box, then right-click on the file path name and and choose "Same as Report".
use below sample code for setting 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);

```