TX Text Control .NET for Windows Forms

Data Sources

Topic

Whether your data lives in business objects, a database, a JSON file or an XML export, MailMerge can merge it, and a template works with every kind as long as the names and the hierarchy match. Each kind of data has its own merge method, can be offered in the Reporting tab for template design and, for databases, can be described by a data source configuration file, a feature of Windows Forms applications.

How Data Reaches a Template

Two classes handle data, for two purposes:

  • MailMerge merges it. Its merge methods take the data and fill the template in a TextControl or ServerTextControl.
  • DataSourceManager describes it. The DataSourceManager of the Reporting tab loads the same kinds of data, analyzes their tables, columns and relations and fills the drop-downs that users insert fields and blocks with.

Every kind of data ends up as tables: the records you merge form the master table, whose columns fill merge fields, and nested collections or related tables fill merge blocks. Overview explains this model.

DataMerge withLoad for design withPage
A business object or a collection of them, dictionariesMergeObject, MergeObjectsLoadSingleObject, LoadObjects, LoadAssemblyObjects and Collections
A DataTable, or a DataSet with relationsMergeLoadDataTable, LoadDataSet, a database connectionDataSets and DataTables
A JSON stringMergeJsonDataLoadJsonJSON and XML
An XML file or stringMerge, after DataSet.ReadXmlLoadXmlFile, LoadXmlStringJSON and XML
A database described by a configuration fileMerge() with ReportDataSourceConfigFileLoadDataSourceConfigData Source Configuration Files

Data Sources in the Reporting Tab

Users choose the data for template design in the Select Data Source drop-down of the Reporting tab, which connects a database or opens an XML file, a JSON file or an assembly, as Data Source in Reporting Ribbon and Dialog Boxes shows. Your code loads data for the users instead, typically in the Load event of the form, as the Getting Started tutorial Create a Template does with invoice.json. The data used for design only needs the structure of the real data; the template is merged later with any data of that structure.

Choose a Data Source

If your data isUse
Classes of your application, or data you query into objectsBusiness objects: Objects and Collections
Rows from a database in ADO.NET formA DataSet with relations: DataSets and DataTables
The response of a web service, a file from another systemJSON or XML: JSON and XML
A database that templates should query by themselvesA configuration file: Data Source Configuration Files

Business objects and JSON are the most direct choices for new applications: they carry the hierarchy of the document without extra relations.

Pages in This Section