The IDataSource Interface


typedef enum tagTransactionSupport
   None = 0, 
   DML = 1, 
   DDLCommit = 2, 
   DDLIgnore = 3, 
   All = 4
} TransactionSupport;

typedef enum tagTransactionIsolation
   ReadUncommited = 0, 
   ReadCommited = 1, 
   RepeatableRead = 2, 
   Serializable = 3
} TransactionIsolation;

interface IDataSource: IDispatch
  [propget, id(0x00000003), helpstring("Gets current connection string.")]
   HRESULT _stdcall ConnectionString([out, retval] BSTR * Value );
  [propput, id(0x00000003), helpstring("Sets current connection string.")]
   HRESULT _stdcall ConnectionString([in] BSTR Value );

  [id(0x00000002), helpstring("Ends transaction for all statements on entire data source.")]
   HRESULT _stdcall Commit( void );

  [id(0x00000004), helpstring("Ends transaction for all statements on entire data source.")]
   HRESULT _stdcall Rollback( void );

  [propget, id(0x00000005), helpstring("Returns the level of transaction support on current data source.")]
   HRESULT _stdcall TransactionSupport([out, retval] TransactionSupport * Value );

  [propget, id(0x00000006), helpstring("True if statements must be re-entered after a transaction end.")]
   HRESULT _stdcall TXKillStatement([out, retval] VARIANT_BOOL * Value );

  [propget, id(0x00000007), helpstring("True if there can be more than one transaction per one data source.")]
   HRESULT _stdcall MultipleTXs([out, retval] VARIANT_BOOL * Value );

  [propget, id(0x00000008) , helpstring("True if the auto-commit transaction mode is enabled.")]
   HRESULT _stdcall AutoCommit([out, retval] VARIANT_BOOL * Value );
  [propput, id(0x00000008), helpstring("Enables/Disables the auto-commit transaction mode.")]
   HRESULT _stdcall AutoCommit([in] VARIANT_BOOL Value );

  [propget, id(0x00000009), helpstring("True if data source is/will be opened in the read-only mode.")]
   HRESULT _stdcall OpenReadOnly([out, retval] VARIANT_BOOL * Value );
  [propput, id(0x00000009), helpstring("Enables/Disables the read/write mode.")]
   HRESULT _stdcall OpenReadOnly([in] VARIANT_BOOL Value );

  [propget, id(0x0000000A), helpstring("Returns the current level of transaction isolation.")]
   HRESULT _stdcall TransactionIsolation([out, retval] TransactionIsolation * Value );
  [propput, id(0x0000000A), helpstring("Sets transaction isolation level.")]
   HRESULT _stdcall TransactionIsolation([in] TransactionIsolation Value );

  [propget, id(0x0000000B), helpstring("True if driver needs to know size of binary data to be sent.")]
   HRESULT _stdcall DataSizeNeeded([out, retval] VARIANT_BOOL * Value );

  [propget, id(0x0000000C), helpstring("True if connected to a data source..")]
   HRESULT _stdcall Connected([out, retval] VARIANT_BOOL * Value );
  [propput, id(0x0000000C), helpstring("Connects to/Disconnects from a data source.")]
   HRESULT _stdcall Connected([in] VARIANT_BOOL Value );

  [propget, id(0x0000000D), helpstring("True if assignment to ConnectionString also connects to a data source.")]
   HRESULT _stdcall AutoConnect([out, retval] VARIANT_BOOL * Value );
  [propput, id(0x0000000D), helpstring("Enables/Disables automatic connecting on ConnectionString assignment.")]
   HRESULT _stdcall AutoConnect([in] VARIANT_BOOL Value );

  [id(0x0000000E), helpstring("Creates new statement to handle non-catalog data.")]
   HRESULT _stdcall CreateStatement([out, retval] IStatement ** result );

  [id(0x0000000F), helpstring("Creates new statement to handle catalog data.")]
   HRESULT _stdcall CreateCatalogStatement([out, retval] ICatalogStatement ** result );

The object implementing the IDataSource interface provides a set of methods and properties to connect to data sources, to retrieve data source specific information, to create statements to access data and catalog including the transaction handling.

The connection string describes each connection to a data source - see Creating Connections. A connection can be opened either in read-only or read/write mode. However a connection string may carry this information, Sequel always overrides it via the OpenReadOnly property. Therefore you have to set it before a connection is made; by default its value is false. If the AutoConnect property is set to true the connection will be established automatically on assignment to ConnectionString property without any need to set the Connected property to true. In this way a driver-specific dialog may appear to ask user for additional data.

The IDataSource interface also defines method to handle transactions. You can use either the auto-commit or manual mode. Use the AutoCommit property to switch between them. When switching to the auto-commit mode, the current transaction is committed; by default the auto-commit mode is set. In this mode each entered statement is committed as it is being executed - i.e. there's no chance to rollback. The level of transaction isolation is controlled via the TransactionIsolation property. Not all drivers support all levels. The transaction support may be examined by the TransactionSupport, MultipleTXs and TXKillStatement properties. For more see Transactions.

If sending binary data, some drivers need to know the exact size. This is indicated with taken of DataSizeNeeded property.