Question about Loading from XML

Hi everyone. I'm trying to load a report from an XML file, and I keep getting the below errors:

Here is my code:

//Create Dataset
DataSet EstimateDS = new DataSet();
EstimateDS.ReadXml(Environment.CurrentDirectory + "//EstimateSample3.xml");

FastReport.Report report = new FastReport.Report();

//Use if designing report
report.SetParameterValue("FullPathNameOfPictureFile", fullpathname);
report.RegisterData(EstimateDS, "Data");
report.GetDataSource("Data").Enabled = true;
report.Design(true);

At the report.GetDataSource("Data").Enabled = true; line, I am getting an error that "The object is not set to an instance of an object"

There is a Data parent node that holds all of my data.

If I save the xml to a file and attach it as a datasource manually through the report designer, it finds all of my data without an issue. So I'm not sure what I'm doing wrong here.

Thanks Again!

Comments

  • edited 11:09AM
    I just wanted to post back on this to say that I think I have it working.

    I changed my code to use this method of adding the DataSource instead and this works much better for XML.

    foreach (DataSourceBase source in report.Dictionary.DataSources)
    {
    source.Enabled = true;
    }

    Thanks Again!
  • edited 11:09AM
    report.registerdata is case sensitive, referring to https://msdn.microsoft.com/en-us/library/ekw4dh3f.aspx

    give me the same error if i use a code like this:
    using (DataSet ds = new DataSet())
                {
                    ds.ReadXml(@"d:\data.xml");
                    using (FastReport.Report report = new FastReport.Report())
                    {
                        //authors != Authors
                        report.RegisterData(ds, "Authors");
                        report.GetDataSource("Authors").Enabled = true;
                        report.Design(true);
                    }
                }
    
  • edited 11:09AM
    Thank you very much for your help, I really appreciate it!

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.