I've created a report using a XML File as Datasource (ADO.NET Xml). Every ChildNode has a Relation to its parent and I created Databands for every childnode.
Everything is rendered correctly when I preview the report in the designer. But by the time I change the datasource programmatically to another XML file the relations break and will not be used.
As soon as I change to another file and call Synchronize(), new relations are added. The report uses neither my old nor the new relations and basically display everything that is in the file without any structure.
This is the code I use.
Code: Select all
StiReport Report = new StiReport();
Report.Load(@"Resources\XmlTestReport.mrt");
XmlDocument doc = new XmlDocument();
doc.Load(pathToXml);
string datasetName = Report.Dictionary.Databases[0].Name;
XmlReader reader = XmlReader.Create(new StringReader(doc.OuterXml));
System.Data.DataSet dataSet = new System.Data.DataSet(datasetName);
dataSet.ReadXml(reader);
Report.Dictionary.Clear();
dataSet.DataSetName = datasetName;
Report.RegData(datasetName, datasetName, dataSet);
Report.Dictionary.Synchronize();
Report.Show();
Code: Select all
Report.Dictionary.Clear()
Code: Select all
Report.Dictionary.Synchronize();
Another problem is that the report does not render anymore when my XML file is missing some nodes that the report would expect. When I skip the call to
Code: Select all
Report.Dictionary.Clear();
I am using Stimulsoft Reports.Net 2018.2.3.
I have attached a sample project.
ReportInput1.xml works correctly because relations do not matter in this use case.
ReportInput2.xml is not rendering because there missing xml nodes - if you comment out Dictionary.Clear() it will render.
ReportInput3.xml is not rendering correctly because relations are broken.
Can you please look into this and tell me how to handle this?
thank you