Omnis Technical Note TNSQ0015 July 2007
ODBC Administration with Omnis Studio
For Omnis Studio 4.2/4.3 and later
By Gary Ashford
The ODBC DAM included with Omnis Studio 4.3 includes additional methods necessary to enable administration of ODBC System, User and File data sources as well as ODBC drivers. These functions are normally performed by the ODBC Administrator utilitiy under Windows and Mac OS X. This technote briefly describes how many of these functions can now be performed from an Omnis library.
An example library is also provided at the end of this page.
The following session methods have been added to the ODBC DAM.
These features are also documented in the What's New in Studio 4.3? update manual.
(Please note that Omnis Studio 4.3 DAMs are also compatible with Omnis Studio 4.2.)
$getdrivers (lResult) retrieves
a list of all ODBC drivers installed on the system. lResult is
populated with the list of drivers installed and is defined with
the following character columns:
$getdatasources(lResult, kDSNMode) can be
used to retirieve a list of
kDSNMode) retrieves the information defined for the specified
data source or driver as a list of keyword-value pairs. kDSNMode
should be passed as either kODBCSystemDSN, kODBCUserDSN or kODBCDriverInfo.
$getinfo() does not support File DSNs for which standard FileOps
methods can be used to read/modify as required.
$setinfo(cDSNName, kDSNMode, lData) writes
the information contained in lData to the specified Data source
or Driver key in the system information. lData should be defined
with Keyword and Value columns as returned by $getinfo().
$configdsn(kDSNMode, kRequestType, cDriverName
, lAttributes ) allows the specified datasource to be created,
modified or removed.
$getoption(kOption, cAttribute) allows the
value of an ODBC configuration attribute to be retrieved.
$setoption(kOption, cAttribute) allows the value
of an ODBC configuration attribute to be modified.
In addition, the session property; $uselogonprompt now accepts the following
kODBCPromptNever (0), kODBCPromptComplete (1) & kODBCPromptAlways (2).
kODBCPromptAlways is used to force the ODBC Administrator library to display a configuration dialogue for example- when connecting to File DSNs.
As you can see from above, several new constants have also been added to help with ODBC administration. These can be found in the Omnis Catalog (F9) listed under "ODBCDAM".
The use of these methods is best illustrated by the following example.
The odbcadmin.lbs library puts all of these attributes to use to create an ODBC Administrator- similar to those provided by Microsoft and Apple, which can either be used stand-alone or as the starting point for your own ODBC administration tool.
Note: If using Omnis Studio 4.2, please remember to replace your ODBC DAM before trying the library!