Omnis Technical Note TNSQ0015July 2007. Updated Sept 2023.
ODBC Administration with Omnis Studio
For Omnis Studio 4.3 and later
By Gary Ashford
Introduction
The ODBC DAM provides additional methods
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 utility 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.
New Features
The following session methods have been added to the ODBC DAM.
Please refer to the online documentation
for further details on session properties and methods that the ODBC DAM provides.
$getdrivers() | $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:
Example: Do tSess.$getdrivers(iDriverList) Returns #F |
||||
$getdatasources() | $getdatasources(lResult, kDSNMode) can be used to retrieve a list of ODBC System or User DSNs.
Example: Do tSess.$getdatasources(iDSNList,kODBCSystemDSN) Returns #F |
||||
$getinfo() | $getinfo(lResult, cDSNName, 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.
Example: Do tSess.$getinfo(lDSNInfo,lHostname,kODBCUserDSN) Returns #F |
||||
$setinfo() | $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() | $configdsn(kDSNMode, kRequestType, cDriverName, lAttributes ) allows the specified datasource to be created, modified or removed.
but can also include other keywords that are allowed by the driver.
Example: Do sessObj.$configdsn(kODBCUserDSN,kODBCAddDSN,'SQL Server',lAttribList) Returns #F |
||||
$getoption() | $getoption(kOption, cAttribute) allows the value of an ODBC configuration attribute to be retrieved.
On return, cAttribute contains the value of the requested option as a character string. Example: Do sessObj.$getoption(kODBCFileDSNDir,iFileDSNDir) Returns #F |
||||
$setoption() | $setoption(kOption, cAttribute) allows the value of an ODBC configuration attribute to be modified.
cAttribute should contain a character string representing the new value for the specified configuration option. Example: Do sessObj.$setoption(kODBCTraceFile,iTraceFile) Returns #F |
Additionally, the session property; $uselogonprompt now accepts the following constant values:
- kODBCPromptNever - Additional logon prompts are disabled
- kODBCPromptComplete - Prompt for missing information only
- kODBCPromptAlways - Always display a logon prompt
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 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".
Example Library
The odbcadmin.lbs library uses the methods above 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.
|