Mitech Preloader

Save the Dataset into a Database Column


Save the Dataset into a Database Column

There are any number of reasons that you might want to save the dataset for a template into a single column in as database.  One of these would be to report on the data set, as described here.

The first step is to write the dataset into a column.  This is described in the GetDataset article.

But once the dataset is in a single column like this, you might want to retrieve it into the data set (using the LinkToDataSource command, or IncludeDataSourceData command for example).

Suppose you had stored the dataset in a column called “XML” in the database, and in a row where the primary key (and the ID of the data source) is “AccountNumber”. This saving of the dataset would have been achieved using SetDataSourceData,  something like this:

«SetDataSourceData(‘AccountDataSource’,AccountNumber, 'XML',GetDataset())»

You could get the same row in the database into your dataset when running a template by using


If you tried this, you would notice that the dataset column would be retrieved into your template’s dataset as a complex XML element with the parent being named “XML” (i.e. the name of the column). This is probably not what you would like. If you change the configuration of the data source slightly, then the dataset from the database XML column will be retrieved directly under to the root of the template’s dataset, and not under a parent called <XML>.

Here’s how to change the configuration:

Once you have configured the data source, you are able to edit the data source’s definition string, using the “Use Data Source’s Editor” button, as in the screenshot:

After that, select the Collection node in the treeview on the left. At the bottom right of the user interface, you will see something like this:

This is where the column containing the XML data set can be specified.

Once this is done, when that particular data source is used to retrieve the row in the database, then the XML data in the XML column will be inserted into the correct place in the XML hierarchy in the current data set.