Quantcast
Channel: SCN : Unanswered Discussions - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 2556

Load XML data file in Report only with the code

$
0
0

Hi,

 

I try to load XML files, who contains data, in my report. In the first time, I make my report in Crystal Report XI R2, and connect database with XML File. Then I try this code :


ReportDocument rapport = newReportDocument();

rapport.Load(@"C:\\tmp\\Crystal\\test.rpt");

rapport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, resPath);

 

But I have a exception : exception1.PNG

 

 

Next, I try to load directly my XML file :

 

ReportDocument rapport = newReportDocument();

rapport.Load(rptPath);

DataSet reportData = newDataSet();

reportData.ReadXmlSchema(@"C:\\tmp\\Crystal\\test.xsd");

reportData.ReadXml(@"C:\\tmp\\Crystal\\test.xml");

rapport.SetDataSource(reportData);

 

But I've 1 or more XML files of data, and I have a exception :

exception2.PNG

And to finish, I try to change the path of my XML files in the report :


ReportDocument crystal = newReportDocument();

crystal.Load(@"C:\\tmp\\Crystal\\test.rpt");

var tables = crystal.Database.Tables;

for (int i = 0; i < tables.Count; i++)

{

    var table = tables[i];

    var nomTable = table.Name;

 

    Char delimiter = '/';

    if (nomTable.Split(delimiter).Length > 1)

    {

        nomTable = nomTable.Split(delimiter)[1];

    }

 

    var info = table.LogOnInfo;

    var cInfo = info.ConnectionInfo;

    cInfo.ServerName = exportPath + "test_" + nomTable + ".xml";

    cInfo.DatabaseName = exportPath + "test.xsd";

 

    info.ConnectionInfo = cInfo;

    table.ApplyLogOnInfo(info);

}

crystal.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, resPath);

 

And I've once again a exception :

exception3.PNG

 

Please, have you got any other solutions or samples to load XML file's data in a report ?

 

Thanks.

 

Matthieu


Viewing all articles
Browse latest Browse all 2556

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>