In OLE DB, a data source object is a COM object through which a consumer connects to a provider's underlying data store.
It is important to distinguish a provider's data source object, which provides data from the data store to a consumer, from the data store itself, which contains the data but interacts with the consumer only through the data source object. For example, a data store might be a comma-separated-value (CSV) text file, an SQL DBMS, or an in-memory array in an application.
In OLEDB Direct Components Suite data source is represented by TOLEDBDataSource object. To open the datasource you should set its ClassID, properties and call Open method. When you no longer need the data source object you just call Close method on it.
uses OLEDB26, OLEDBComponents;
var
ds: TOLEDBDataSource;
//Open Microsoft Jet OLEDB provider
dsDataSource.ClassID := CLSID_JETOLEDB_4_00;
ds.Properties[DBPROPSET_DBINIT][DBPROP_INIT_DATASOURCE].Value := 'c:\my documents\mydb.mdb';
ds.Open;
//---------------------------------------------------------------
//Open Microsoft SQL Server provider
dsDataSource.ClassID := CLSID_SQLOLEDB;
//Connect to SQL Server using Windows authentification
dsDataSource.Properties[DBPROPSET_DBINIT][DBPROP_AUTH_INTEGRATED].Value := '';
//Connect to SQL Server using its authentification
//dsDataSource.Properties[DBPROPSET_DBINIT][DBPROP_AUTH_USERID].Value := 'sa';
//dsDataSource.Properties[DBPROPSET_DBINIT][DBPROP_AUTH_PASSWORD].Value := '';
dsDataSource.Properties[DBPROPSET_DBINIT][DBPROP_INIT_CATALOG].Value := 'pubs';
dsDataSource.Open;
//---------------------------------------------------------------
//Open ODBC provider for Microsoft Access
dsDataSource.ClassID := CLSID_MSDASQL;
dsDataSource.Properties[DBPROPSET_DBINIT][DBPROP_INIT_PROVIDERSTRING].Value :=
'Driver={Microsoft Access Driver (*.mdb)}';
dsDataSource.Properties[DBPROPSET_DBINIT][DBPROP_INIT_CATALOG].Value :=
'c:\my documents\mydb.mdb';
dsDataSource.Open;
//---------------------------------------------------------------
//Open Microsoft Jet provider for dBase
dsDataSource.ClassID := CLSID_JETOLEDB_4_00;
dsDataSource.Properties[DBPROPSET_JETOLEDB_DBINIT][DBPROP_JETOLEDB_ENGINE].Value :=
JETDBENGINETYPE_DBASE5;
dsDataSource.DBName := 'c:\my documents\';
dsDataSource.Open;
//---------------------------------------------------------------
//Open ODBC provider for dBase
dsDataSource.ClassID := CLSID_MSDASQL;
dsDataSource.Properties[DBPROPSET_DBINIT][DBPROP_INIT_PROVIDERSTRING].Value :=
'DRIVER={Microsoft dBase Driver (*.dbf)}';
dsDataSource.Properties[DBPROPSET_DBINIT][DBPROP_INIT_CATALOG].Value :=
'c:\my documents';
dsDataSource.Open;
//---------------------------------------------------------------
//Open Microsoft Jet provider for Excel
dsDataSource.ClassID := CLSID_JETOLEDB_4_00;
dsDataSource.Properties[DBPROPSET_JETOLEDB_DBINIT][DBPROP_JETOLEDB_ENGINE].Value :=
JETDBENGINETYPE_EXCEL80;
dsDataSource.DBName := 'c:\my documents\myxlsfile.xls';
dsDataSource.Open;