怎样实现数据源列表
API声明:
FUNCTION integer SQLAllocEnv(ref long henv) LIBRARY "odbc32.dll"
FUNCTION integer SQLFreeEnv(long henv) LIBRARY "odbc32.dll"
int idsnmax, ref integer idsn, ref string szdesc, integer idescmax, &
ref integer idesc) library "odbc32.dll"
调用:
string ls_dsn, ls_desc
integer li_direction
integer li_dsnmax, li_descmax
integer li_dsnlen, li_desclen
integer li_rc
integer li_length
integer li_i
long ll_henv
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", "失败!")
ELSE
li_i = 0
li_direction = 1
DO WHILE SQLDataSources &
(ll_henv, li_direction, ls_dsn, li_dsnmax, li_dsnlen, &
ls_desc, li_descmax, li_desclen) = 0
li_i ++
//添加到列表框
ddlb_odbc.AddItem(ls_dsn)
// 保存到数组
is_desc[li_i] = ls_desc
LOOP
SQLFreeEnv(ll_henv)
END IF