JobDataOdbc class
Namespace: TECIT.TFORMer
Provides access to JobDataOdbc (an ODBC connection that serves as JobData for a Job).
Usage and notes
Overview
An ODBC query supplies records from database tables for generating output. Use JobDataOdbc to supply the query results as the JobData of a Job.
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:
// Set the DSN programmatically
jobDataOdbc.Dsn = "DSN=TFORMer_Sample";
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.
// Create a new Job instance
Job printJob = new Job();
// 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
printJob.RepositoryName = "C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/9/Examples/Command Line/ODBCReportPDF/ODBCReportPDF.tff";
// Create a new JobData instance using the installed sample ODBC connection named TFORMer_Sample
JobData jobData = new JobDataOdbc("DSN=TFORMer_Sample", "", "", "SELECT * FROM tbl_Example");
// Assign the JobData to the Job
printJob.JobData = jobData;
// Select PDF output to /temp/out.pdf
printJob.OutputName = "/temp/out.pdf";
printJob.PrinterType = PrinterType.PdfFile;
// Generate output based on the FormLayout and the JobData
printJob.Print ();
More Information
For a general description see JobData.
See also
Note
Thread-safety: A single instance of this class must not be used by different threads.
Inheritance and related types
Base types: JobData
Inherited members (2)
Constructors
| Member | Description |
|---|---|
| JobDataOdbc() | Constructor for JobDataOdbc. |
| JobDataOdbc(string, string, string, string) | Constructor for JobDataOdbc. |
Properties
| Member | Description |
|---|---|
| Dsn | Gets/Sets the DSN (ODBC data-source-name). |
| Password | Gets/Sets the password for the database connection. |
| RecordCopyDataField | |
| SqlSelect | Gets/Sets the SQL select statement for fetching the records from the database. |
| User | Gets/Sets the user-name for the database connection. |