Executing the example requires the database MS ACCESS with the name db1.mdb. The database contains a table with the Instruction name.
Sub Main;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
ODBC: IOdbcDataset;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_ODBC_DS;
CrInfo.Id := "NewODBCDataset";
CrInfo.Name: = "New ODBC data source";
CrInfo.Parent := MB.Root;
ODBC := MB.CreateObject(CrInfo).Edit As IOdbcDataset;
ODBC.Catalog := "C:\db1.mdb";
ODBC.DataSource: = "MS Access database";
ODBC.DataSourceName := "Instruction";
(ODBC As IMetabaseObject).Save;
End Sub Main;
After executing the example, a new ODBC data source is created in repository root. This source is set up to access the Instruction data table, contained in the database MS ACCESS.
See also: