JobDataOdbc
Overview
An ODBC query supplies records from database tables for generating output. Use TFormer_SetODBCData to specify the connection and SQL SELECT statement.
The data in such a table provides the values of the DataFields. The table is read Record by Record using the specified SQL SELECT statement. TFORMer SDK matches the column-names of the table or query with the corresponding DataField names in the FormLayout. If required use SQL aliases to provide identical column names.
The order of the columns in the table or query does not matter.
The DSN identifies an ODBC data source configured on the system. On Windows, configure it using the ODBC Data Source Administrator. Include DSN=... in the connection string, as shown below.
This may yield the following code:
eCode = TFormer_SetODBCData (hTForm, "DSN=TFORMer_Sample", "", "", "SELECT * FROM tbl_Example");
Example
This example assumes an ODBC data source named TFORMer_Sample with the table tbl_Example shown below.
ChapterNumber | Caption | PageNumber |
|---|---|---|
1 | Content | 2 |
1.1 | Table of Figures | 6 |
1.2 | List of Tables | 6 |
2 | Disclaimer | 7 |
... | ... | ... |
The following example uses this table to generate PDF output.
// Select the stand-alone FormLayout named ODBCReportPDF.tff
// This FormLayout is usually installed as part of the TFORMer Examples in
// - Windows Vista or later: C:/Program Data/TEC-IT/TFORMer/9/Examples
// - Older Microsoft Windows versions: C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/9/Examples
eCode = TFormer_SetRepositoryName (hTForm, "C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/9/Examples/Command Line/ODBCReportPDF/ODBCReportPDF.tff");
// Here we are using the installed sample ODBC connection named TFORMer_Sample
eCode = TFormer_SetODBCData (hTForm, "DSN=TFORMer_Sample", "", "", "SELECT * FROM tbl_Example");
// 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.