List available ODBC datasourcesTag(s): Database
You need to declare the following external functions :
FUNCTION integer SQLAllocEnv(ref long henv) LIBRARY "odbc32.dll" FUNCTION integer SQLFreeEnv(long henv) LIBRARY "odbc32.dll" FUNCTION integer SQLDataSources & (long henv, integer idirection, ref string szdsn, int idsnmax, & ref integer idsn, ref string szdesc, integer idescmax, ref integer idesc) & library "odbc32.dll"
long ll_henv
string ls_dsn, ls_desc
integer li_direction, li_dsnmax, li_dsnlen, li_descmax, li_desclen, li_rc
integer li_length = 255
ls_dsn = Space(li_length)
li_dsnmax = li_length
ls_desc = Space(li_length)
li_descmax = li_length
IF SQLAllocEnv(ll_henv) = -1 THEN
MessageBox("SQLAllocEnv", "FAILURE")
ELSE
li_direction = 1
DO WHILE SQLDataSources &
(ll_henv, li_direction, ls_dsn, li_dsnmax, li_dsnlen, &
ls_desc, li_descmax, li_desclen) = 0
ddlb_1.AddItem(ls_dsn + " [" + ls_desc + "]")
LOOP
SQLFreeEnv(ll_henv)
END IF
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com