JobDataDataSource
Overview
A data source defined for a FormLayout supplies input records for generating output. Select it with TFormer_SetDatasourceName. Set parameter values with TFormer_SetDSParameterValue after selecting the data source and before generating output.
The creator of a FormLayout is able to define such a DataSource with TFORMer Designer. This DataSource definition is stored as part of the FormLayout and is identified by a unique name. It defines how data is retrieved (e.g. from an ODBC database), the field-mappings and optional DataSourceParameters.
Pass NULL or an empty name to TFormer_SetDatasourceName to use the DataSource selected in the FormLayout. This need not be the special _Default_ source.
The _Default_ source reads the DataField values saved by TFORMer Designer alongside the layout in its companion .xml file. The SDK also falls back to that file when no source is selected in the layout. If this file supplies the input and is absent, its saved records are not available for output.
The optional DataSourceParameters can change settings such as the input filename, SQL SELECT statement or ODBC DSN at runtime.
Examples
The following example selects a data source defined in the form layout and generates a PDF file.
// Select the stand-alone FormLayout named (6) Samples_Picking List.tff
// This FormLayout is usually installed as part of TFORMer in
// - Windows Vista or later: C:/Program Data/TEC-IT/TFORMer/9/Templates
// - Older versions of Microsoft Windows: C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/9/Templates
TFormer_SetRepositoryName (hTForm, "C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/9/Templates/(6) Samples_Picking List.tff");
// Here we are using the DataSource named "ODBC" defined inside the Formlayout
eCode = TFormer_SetDatasourceName (hTForm, "ODBC");
// Select PDF output
if (eCode == ErrOk)
eCode = TFormer_SetPrinterType (hTForm, ePrinterType_PDFFile);
// To /temp/out.pdf
if (eCode == ErrOk)
eCode = TFormer_SetOutputName (hTForm, "/temp/out.pdf");
// Generate output based on the FormLayout and the JobData
if (eCode == ErrOk)
eCode = TFormer_Print (hTForm);
More Information
For a general description see JobData.