Connecting to Data from Code
Our sample projects and report templates can help you learn the basics of working with our products.A report's data can be supplied entirely from code. This example builds a dataset from JSON and registers it with the report before showing it.
Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
Preparing the data. Read or create the data source, register it in the report dictionary, synchronize the schema, and render with the supplied records.
private void ShowReport(DataSet dataSet)
{
var report = new StiReport();
report.Load(@"Reports\TwoSimpleLists.mrt");
report.Dictionary.Databases.Clear();
report.RegData("Demo", dataSet);
report.ShowWithWpf();
}
// build the data (here from a JSON file) and show it
var dataSet = StiJsonToDataSetConverterV2.GetDataSetFromFile(@"Data\Demo.json");
ShowReport(dataSet);RegData makes the object available to the report engine, and Dictionary.Databases.Clear() removes the template's design-time connections so only your run-time data is used.