IDataSource interface

Library: TFORMer9Lib

Abstract class for a DataSource.

Usage and notes

Overview

TFORMer Designer allows to define a DataSource as part of a FormLayout. Such an user-defined DataSource can be used for printing directly from within TFORmer Designer or may be re-used by TFORmer SDK for providing JobData (see JobDataDataSource).

A DataSource defines how data is retrieved (e.g. from an ODBC database), the field-mappings (see DSFieldMapping), computed fields (see ComputedField) and optional data source parameters (see DataSourceParameter). Each DataSource is identified by its unique name. Optional DataSourceParameters can be defined to control certain aspects (like filenames, SQL statement or an ODBC-DSN) during runtime.

By default TFORMer Designer creates a DataSource named _Default_. This DataSource is used for printing as long as neither a DataSource is specified for JobData nor the FormLayout has an active DataSource set in design. This DataSource retrieves the data from the file that is stored along with the FormLayout file (extension .xml) and contains the DataField values entered during the last TFORMer Designer session.

The available data-source types are DataSourceCsv, DataSourceOdbc and DataSourceXml.

Escape Sequences

For a configured DataSource, escape-sequence handling is controlled by the source definition. Configure this behavior in TFORMer Designer. It is separate from the direct-input JobData setting. See Escape Sequences for the supported sequences.

Record Copies

Each Record of a DataSource is usually considered exactly once for generating output. Use DataSource.CopyColumnName to select the source field containing the copy count. This feature is helpful whenever a single Record of a DataSource should be printed multiple times (e.g. if a certain number of identical labels should be printed).

Computed Fields

Computations can be centralized in the DataSource instead of performing the computations in the FormLayout. The result of a ComputedField is available in the DataSource like any other source-field.

Examples

Sample code that iterates all DataSource of a given Repository:

Sub IterateDataSourcesProject (project)
  Dim datasource  
  Dim dsParam
  Dim dsComp
  Dim dsFieldMap

  ' Iterate all DataSources of the Project '
  Set dataSource = project.FirstDataSource
  While Not (dataSource Is Nothing)
    MsgBox dataSource.Name

    ' Print information for the DataSourceParameters of the DataSource '
    Set dsParam = dataSource.FirstParameter
    While Not (dsParam Is Nothing)
      MsgBox dsParam.Name
      Set dsParam = dsParam.Next
    Wend

    ' Print information for the ComputedFields of the DataSource '
    Set dsComp = dataSource.FirstComputedField
    While Not (dsComp Is Nothing)
      MsgBox dsComp.Name
      Set dsComp = dsComp.Next
    Wend

    ' Print the mapping between source fields and DataFields '
    Set dsFieldMap = dataSource.FirstFieldMapping
    While Not (dsFieldMap Is Nothing)
      MsgBox dsFieldMap.DataField & " <- " & dsFieldMap.SourceField
      Set dsFieldMap = dsFieldMap.Next
    Wend

    ' Get the next DataSource '
    Set dataSource = dataSource.Next
  Wend
End Sub
  ' Create TFORMer SDK instance '
  Set tformer = CreateObject("TFORMer9Lib.TFORMer")

  ' Create a new Repository instance using a Repository (extension *.tfr) '
  ' Examples are usually installed in '
  ' - Windows Vista: 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 '
  Set repository = tformer.LoadRepository("C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/9/Examples/Demo Repository/Demos.tfr", True)
  ' Iterate the DataSources of the global Project '
  ' If a Repository is used, the global Project and additional user-defined Projects may exist '
  MsgBox "Global project"
  IterateDataSourcesProject (repository.GlobalProject)

  ' Iterate additional Projects '
  ' Additional Projects are only possible when using a Repository '
  Set project = repository.FirstProject
  While Not (project Is Nothing)
    MsgBox project.Name

    ' Iterate the DataSources of the Project '
    IterateDataSourcesProject (project)

    ' Get the next Project '
    Set project = project.Next
  Wend

Sample code that iterates all DataSource-objects of a given stand-alone FormLayout:

Sub IterateDataSourcesProject (project)
  Dim datasource  
  Dim dsParam
  Dim dsComp
  Dim dsFieldMap

  ' Iterate all DataSources of the Project '
  Set dataSource = project.FirstDataSource
  While Not (dataSource Is Nothing)
    MsgBox dataSource.Name

    ' Print information for the DataSourceParameters of the DataSource '
    Set dsParam = dataSource.FirstParameter
    While Not (dsParam Is Nothing)
      MsgBox dsParam.Name
      Set dsParam = dsParam.Next
    Wend

    ' Print information for the ComputedFields of the DataSource '
    Set dsComp = dataSource.FirstComputedField
    While Not (dsComp Is Nothing)
      MsgBox dsComp.Name
      Set dsComp = dsComp.Next
    Wend

    ' Print the mapping between source fields and DataFields '
    Set dsFieldMap = dataSource.FirstFieldMapping
    While Not (dsFieldMap Is Nothing)
      MsgBox dsFieldMap.DataField & " <- " & dsFieldMap.SourceField
      Set dsFieldMap = dsFieldMap.Next
    Wend

    ' Get the next DataSource '
    Set dataSource = dataSource.Next
  Wend
End Sub
  ' Create TFORMer SDK instance '
  Set tformer = CreateObject("TFORMer9Lib.TFORMer")

  ' Create a new Repository instance using a stand-alone FormLayout (extension *.tff) '
  ' Examples are usually installed 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 '
  Set repository = tformer.LoadRepository("C:/Documents and Settings/All Users/Application Data/TEC-IT/TFORMer/9/Examples/Command Line/ODBCReportPDF/ODBCReportPDF.tff", True)
  ' Iterate the DataSources of the global Project '
  ' If a stand-alone FormLayout is used, the global Project is the only Project '
  MsgBox "Global project"
  IterateDataSourcesProject (repository.GlobalProject)

More Information

See also

ComputedField

Related documentation:

Note

Thread-safety: A single instance of this class must not be used by different threads.

See also

DataSourceCsv, DataSourceOdbc, DataSourceXml

Base types: IDispatch

Derived types: IDataSourceCsv, IDataSourceOdbc, IDataSourceXml

Properties

MemberDescription
CommentString { get; set; }

Gets/Sets the comment for the DataSource.

CopyColumnNameString { get; set; }

Gets/Sets the CopyColumnName of the DataSource.

DescriptionString { get; set; }

Gets/Sets the description of the DataSource.

FirstComputedFieldIComputedField { get; }

Gets the first ComputedField defined in the DataSource.

FirstFieldMappingIDSFieldMapping { get; }

Gets the first DSFieldMapping defined in the DataSource.

FirstParameterIDataSourceParameter { get; }

Gets the first DataSourceParameter defined in the DataSource.

HandleEscapeSequencesBoolean { get; set; }

Gets/Sets if escape sequences should be translated on data retrieval or not.

IsDefaultBoolean { get; }

Gets a value indicating whether this object stores the default DataSource.

NameString { get; set; }

Gets/Sets the name of the DataSource.

NextIDataSource { get; }

Gets the next DataSource instance defined in the Project.

NumberOfComputedFieldsLONG { get; }

Gets the number of ComputedFields defined in the DataSource.

NumberOfFieldMappingsLONG { get; }

Gets the number of DSFieldMappings defined in the DataSource.

NumberOfParametersLONG { get; }

Gets the number of DataSourceParameters defined in the DataSource.

TypeDataSourceType { get; }

Gets the type of the DataSource.

Methods

MemberDescription
AddComputedField(String)Returns: IComputedField

Creates and adds a ComputedField to the DataSource.

AddFieldMapping(String)Returns: IDSFieldMapping

Creates and adds a DSFieldMapping to the DataSource.

AddParameter(String)Returns: IDataSourceParameter

Creates and adds a DataSourceParameter to the DataSource.

GetComputedField(String)Returns: IComputedField

Gets a ComputedField defined in the DataSource.

GetFieldMapping(String)Returns: IDSFieldMapping

Gets a DSFieldMapping defined in the DataSource.

GetParameter(String)Returns: IDataSourceParameter

Gets a DataSourceParameter defined in the DataSource.

RemoveComputedField(IComputedField)

Removes the ComputedField from the DataSource.

RemoveFieldMapping(IDSFieldMapping)

Removes the DSFieldMapping from the DataSource.

RemoveParameter(IDataSourceParameter)

Removes the DataSourceParameter from the DataSource.

Search documentation

Search in
More scopes
Additional scopes

All contents