TX Text Control .NET for WPF

Data Source Configuration Files

Topic

Report Data Source Configuration files, XML files with the extension .rdsc, store a database connection, a master table and the data relations between its tables, so that MailMerge can query a database by itself. They are a feature of Windows Forms applications: WPF applications can't create or use them. If you come across the file type in older samples or in the reference, what follows explains what it does, what stops it from working in WPF and how a WPF application reaches the same result.

What a Configuration File Does

In a Windows Forms application, users connect a database in the Reporting tab, define relations between its tables and save these settings with Config File > Save Configuration. MailMerge then merges a template with the database in one call, reading the connection and the relations from the file. The Windows Forms documentation describes the whole workflow in Data Source Configuration Files.

Why It Doesn't Work in WPF

The reference states that data source configuration files can only be used in Windows Forms applications. In WPF:

  • LoadDataSourceConfig and SaveDataSourceConfig of the DataSourceManager throw an exception when a WPF application calls them.
  • The WPF RibbonReportingTab has no Config File button. Its Select Data Source drop-down offers Load XML File, Load Assembly and Load JSON File, but no command that connects a database.
  • A configuration file can only be saved for a database connected through the DatabaseConnectionDialog, a Windows Forms dialog box that has no WPF counterpart.

The properties ReportDataSourceConfigFile and ReportDataSourceConfig of MailMerge are listed in the WPF reference because MailMerge is the same class in all TX Text Control .NET products. They are the Windows Forms route to configuration files and don't make the files usable in WPF.

What to Do Instead in WPF

A configuration file combines three things, and a WPF application provides each of them in code:

The file storesIn a WPF application
The connection to the databaseYour code queries the database, for example with a DataAdapter or Entity Framework
The master tableThe table or collection your code passes to the merge method
The data relationsDataRelation objects in the DataSet, or collections nested in business objects

Merge Related Tables builds such a DataSet with an invoice and its items, adds the relation that a configuration file would have held and merges the master table into the template in the editor. In your application, fill the tables from the database instead of building them in memory.

To let users design templates for this data, load the same DataSet into the Reporting tab with LoadDataSet. Its relations appear in the tab like those of a configuration file, and users can add more with Edit Data Relations; keep your code's relations in line with them, because the designer's relations aren't saved.

When the data has to be read by another program or at another time, save it as JSON or XML instead of a configuration file: both formats carry the hierarchy with the data and are merged as JSON and XML describes.

Next Steps