# Data Sources

> Data sources for mail merge in WPF: objects, DataSets, JSON and XML, the MailMerge method for each and the DataSourceManager of the WPF Reporting tab.

- **Product:** TX Text Control .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for WPF > Mail Merge and Reporting > Data Sources
- **984 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/llms-full.txt

---

If you are about to connect your WPF application's data to a template, the first question is what form that data has today: classes, ADO.NET tables, JSON or XML. `MailMerge` merges each of them, and one template serves them all as long as names and hierarchy match. Here you find which method merges which kind of data, how the **Reporting** tab receives the same data for template design and which page covers each kind.

### How Data Reaches a Template

Two classes work with the data:

- **`MailMerge` merges it.** A merge method takes the data and fills the template in a `TextControl` or `ServerTextControl`.
- **`DataSourceManager` describes it.** The [DataSourceManager](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/ribbonreportingtab/datasourcemanager-property/llms-full.txt) of the WPF Reporting tab loads the same kinds of data, analyzes their tables, columns and relations and fills the drop-downs from which users insert fields and blocks.

Whatever the kind, the data becomes tables: the records you merge form the master table, whose columns fill merge fields, and nested collections or related tables fill merge blocks. [Overview](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/overview/#pre-shaped-data) explains this model.

| Data | Merge with | Load for design with | Page |
|---|---|---|---|
| A business object or a collection of them, dictionaries | [MergeObject](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/mergeobject-method/llms-full.txt), [MergeObjects](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/mergeobjects-method/llms-full.txt) | `LoadSingleObject`, `LoadObjects`, `LoadAssembly` | [Objects and Collections](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/objects/llms-full.txt) |
| A `DataTable`, or a `DataSet` with relations | [Merge](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/merge-method/llms-full.txt) | `LoadDataTable`, `LoadDataSet` | [DataSets and DataTables](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/datasets/llms-full.txt) |
| A JSON string | [MergeJsonData](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-documentserver/mailmerge/mergejsondata-method/llms-full.txt) | `LoadJson` | [JSON and XML](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/json-xml/llms-full.txt) |
| An XML file or string | `Merge`, after `DataSet.ReadXml` | `LoadXmlFile`, `LoadXmlString` | [JSON and XML](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/json-xml/llms-full.txt) |

Data source configuration files, which store a database connection for the merge, are a Windows Forms feature; [Data Source Configuration Files](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/configuration-files/llms-full.txt) explains what WPF applications do instead.

### Data Sources in the Reporting Tab

With **Select Data Source**, users of the WPF Reporting tab load an XML file, an assembly or a JSON file for template design; data from a database reaches the tab only through your code, because the WPF tab can't connect a database. [Reporting Ribbon and WPF Dialog Boxes](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/ribbon-dialogs/#data-source) describes the commands, and each page of this section shows the `DataSourceManager` method that loads its kind of data.

### Choose a Data Source

| If your data is | Use |
|---|---|
| Classes or view models of your application, or data you query into objects | Business objects: [Objects and Collections](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/objects/llms-full.txt) |
| Rows from a database in ADO.NET form | A `DataSet` with relations: [DataSets and DataTables](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/datasets/llms-full.txt) |
| The response of a web service, a file from another system | JSON or XML: [JSON and XML](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/json-xml/llms-full.txt) |

Business objects and JSON carry the hierarchy of the document without extra relations, which makes them the most direct choices for new applications.

### Pages in This Section

- [Objects and Collections](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/objects/llms-full.txt): merge business objects, dictionaries and anonymous objects, rename fields with attributes.
- [DataSets and DataTables](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/datasets/llms-full.txt): merge tables with relations and edit relations in the Reporting tab.
- [JSON and XML](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/json-xml/llms-full.txt): merge JSON, handle invalid JSON, read XML into a `DataSet` and set parsing cultures.
- [Data Source Configuration Files](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/configuration-files/llms-full.txt): why configuration files are Windows Forms only, and the WPF alternative.

---

## In This Section

- [Data Source Configuration Files](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/configuration-files/llms-full.txt): Why Report Data Source Configuration files (.rdsc) work in Windows Forms only, and how WPF apps replace them with DataSets, relations and their own queries.
- [DataSets and DataTables](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/datasets/llms-full.txt): Merge DataTables and related tables of a DataSet in a WPF window, load them into the Reporting tab and edit relations with the WPF EditDataRelationsDialog.
- [JSON and XML](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/json-xml/llms-full.txt): Merge JSON strings and XML files in a WPF application: MergeJsonData, ParserException, relations from DataSet.ReadXml, parsing cultures and LoadJson.
- [Objects and Collections](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/objects/llms-full.txt): Merge WPF view models and business objects with MergeObjects and MergeObject, rename fields with DisplayName and load the classes into the Reporting tab.

---

## Nearby

- **Previous:** [Overview](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/overview/llms-full.txt)
- **Next:** [Objects and Collections](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/mail-merge/data-sources/objects/llms-full.txt)
