Data source is a sub-object to the data object, but can
be instantiated independently. It provides database connection
information and allows running of SQL commands against a connected
database resource (table, view or stored procedure). In most cases, the data
source is set up through the Input data source
editor. The object is exposed as ITDataSource interface. PropertiesvalidThe state of the data source object. True: the database resource is ready to be used through other methods of the data source object. False: the data object is not ready. You can set this property to false to forcefully invalidate an object. Read/Write property To get the variable's value: dsnDsn stands for Data Source Name, which is a server name for an OLEDB connection and an ODBC DSN in for an ODBC connection. This property is not in use for file-based data sources. Read/Write property DS.dsn = "SQLServer" 'OLEDB server
name databaseA database name or a catalog name of the associated database resource. For file-based data sources it is the folder path where the database table is located. Read/Write property DS.database = "MyDatabase" 'OLEDB, ODBC aliasAn alias for the table that can be used in place of the table name. Use it to simplify SQL expressions, which use this resource by name. For example, a complex fully qualified database table name like [Server].[Database].[Schema].[Table Name] can be replaced with something as simply as "Table1". Read/Write property DS.alias = "Table1" tableName of the database resource( table, view, function... ). Read/Write property DS.database = "c:\data\access\my.mdb" 'File based
databases extensionThe database file extension when the database is file-based. Read/Write property DS.database = "c:\data\dbase_files" clsidClassID or ProgID for OLEDB providers. Read/Write property DS.clsid = "MSDASQL" schemaThe schema name of the database resource for data sources which support schemas. Read/Write property DS.schema = "dbo" userUser ID for authentication purposes. Write only property DS.user = "administrator" passwordUser password for authentication purposes. Write only property csv_positionalText/CSV file related property specifying if the output file will be created
as delimited or fields will be positioned accordingly to the fields widths in
the output dictionary. csv_col_separatorText/CSV file related property specifying the character(s) used to separate fields/column values in a CSV or Text file. Read/Write property DS.csv_positional = false
‘delimited file, not positional output csv_include_column_namesText/CSV file related property specifying if the file contains the column names within the file. Read/Write property csv_text_qualifierText/CSV file related property specifying the character(s) which enclose field values. Read/Write property MethodsGetAsStringReturns a fully qualified data source name in form of a string. For example: C:\data\accounts.dbf, SQLServer\DB1\dbo\accounts, etc. Function GetAsString() DS.GetAsString() SetDSInitializes the data source object from another data source object or from a string. (variant) Function SetDS( ds ) Examples:
You can set output table using two methods: setting the table name (assuming you are connected to a database) - (a) and setting the entire data source - (b): If you
are writing script outside TextConverter the API looks like this: DS.table = "tablename" ) ‘- (a) DS.SetDS( "c:\data\output.dbf" ) ‘- (b)
If you are writing script inside TextConverter it looks like this: This.DSOut.table = "tablename" ) ‘- (a) This.DSOut.SetDS( "c:\data\output.dbf" ) ‘- (b)
An Excel file is also considered as a database, so you can set the worksheet as: Set DS = TextConverter.GetOutputDS() DS.table = "worksheetname" ) ‘- (a) DS.SetDS( "...\file.mdb:worksheetname" ) ‘- (b) Additional examples: 'Sample 1 DS.SetDS( ds1 ) 'ds1 - pre initialized data source object 'Sample 2 DS.SetDS( "c:\data\access.mdb" ) 'Sample 3 DS.SetDS( "c:\data\input.csv" )
TableExistsCheck if the underlying database resource exists in the database. Function TableExists() If DS.TableExists() Then DS.Drop() DropRemoves the data source resource from the database. Function Drop() If DS.TableExists() Then DS.Drop() GetRelationReturns a relation object, which defines relations between the two tables, which are passed in as parameters. Use of aliases to identify the tables rather than table names is recommended. Function GetRelation( left, right
) Dim rel ReplaceTableReplaces a table contained in a multi-table dynamic view with another table. Function ReplaceTable( old_name,
new_name ) DS.ReplaceTable "Accounts", AccountsNew" ExecuteExecutes an SQL statement against an underlying data source. Function Execute( sql,
ignore(optional, default = false) ) Dim count CreateCreates a database table according to this data source object setup.
Function Create() DS.Create() |