on 01-11-2017 4:39 PM
Hi,
I designed a report pointing to local XML and XSD files. Now, I want to process the .rpt file programmatically in a .NET 4.6.2 app by specifying a new XML data source. However, after I call SetDataSource and Refresh on the ReportDocument, the report object throws a CrystalDecisions.CrystalReports.Enging.DataSourceException when I call ExportToStream:
{"Fehler beim Laden der Datenbankinformationen.\rFehler in der Datei ExternalXMLReport 1856_6320_{0543C9E8-7559-44A9-BADE-1551F0E603BE}.rpt:\nFehler beim Laden der Datenbankinformationen"}
The corresponding code snippet looks like this:
var report = new ReportDocument();
report.Load("ExternalXMLReport.rpt");
DataSet reportData = new DataSet();
reportData.ReadXml("catalog.xml");
report.SetDataSource(reportData);
report.Refresh();
var pdfStream = report.ExportToStream(ExportFormatType.PortableDocFormat);
How can I avoid this exception?
The goal is to design reports with XML and XSD files locally with the Crystal Reports Designer Desktop Application and passing the latest data to the report at runtime.
I also tried setting the XSD file on the DataSet with no success.
Thanks for your help in advance.
Best Regards,
HP
Hi HP,
Search for KBA 2281780 and download the Parameter Test app, it has the ability to set location to XML data sources and see if that works for you.
Your code is actually loading the XML into a Dataset and you are setting the Reports data source to the DS. You don't need to do that when using XML:
try
{
foreach (CrystalDecisions.CrystalReports.Engine.Table rptTable in rpt.Database.Tables)
{
tLogonInfo = rptTable.LogOnInfo;
tLogonInfo.ConnectionInfo.ServerName = btrDataFile.Text; // Folder where XML file resides
tLogonInfo.ConnectionInfo.DatabaseName = btrSearchPath.Text; // My.xml
//tLogonInfo.ConnectionInfo.UserID = "";
//tLogonInfo.ConnectionInfo.Password = "";
tLogonInfo.TableName = rptTable.Name;
try
{
rptTable.ApplyLogOnInfo(tLogonInfo);
}
catch (Exception ex)
{
MessageBox.Show("ERROR: " + ex.Message);
}
Now export the report.
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Don,
unfortunately, also without Report.Refresh() I get...
Fehler beim Laden der Datenbankinformationen.
Fehler in der Datei ExternalXMLReport1-3 12128_1004_{5BEAC23C-1BB6-42A9-B4A8-72D5BA8245C4}.rpt:
Fehler beim Laden der Datenbankinformationen
Regards,
HP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Don't call Report.Refresh(), it's using the old data connection info.
When you export it will refresh the data.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.