Class OdbcManager() Professional
Manage ODBC data sources
The OdbcManager()-class provides acces to the ODBC manager. It is used to administer ODBC data sources, either interactively or programmatically.
// The sample shows how to add, configure and
// remove a named user data source
#include "sqlcmd.ch"
PROC Main()
LOCAL oMgr
LOCAL cDsn, cDriver
oMgr := OdbcManager():new()
// the name of the DSN and the driver to use
cDsn := "Test"
cDriver := "Microsoft dBase-Treiber (*.dbf)"
// check if name can be used
IF !oMgr:validateDSNName(cDsn)
? "DSN name invalid:"
? "Error(s):",oMgr:getLastError()
ENDIF
cDsn := "DSN="+cDsn
// try to configure DSN, if DSN exists
IF oMgr:configUserDsn(cDriver, cDsn)
? cDsn + " configured"
ELSE
// otherwise, create a new DSN
IF !oMgr:addUserDsn(cDriver, cDsn)
? oMgr:getLastError()
ELSE
? cDsn + " added."
ENDIF
ENDIF
// remove the specified DSN
IF oMgr:removeUserDsn(cDriver, cDsn)
? cDsn + " removed."
ELSE
? "Error(s):", oMgr:getLastError()
ENDIF
RETURN
// This sample demonstrates how to retrieve information
// about data sources, and how to work
// with predefined dialogs
#include "sqlcmd.ch"
PROC Main()
LOCAL oMgr
LOCAL cDsn, cDriver
oMgr := OdbcManager():new()
// list all installed drivers
? oMgr:getDrivers()
// list data sources
? oMgr:getDSNs()
// return path to ODBC DLL's
? oMgr:getOdbcInstallPath()
// pop-up the ODBC Administrator dialog
// to let the user manage data sources interactively
oMgr:showAdministrator()
// pop-up the "Create Data Source"- dialog
// to let the user create a new data sources interactively
oMgr:createDSNDialog()
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.