Article ID: 155809
Article Last Modified on 7/13/2004
#DEFINE SQL_FETCH_NEXT 1
#DEFINE SQL_FETCH_FIRST 2
#DEFINE SQL_SUCCESS 0
#DEFINE MAX_STRING 128
DECLARE INTEGER SQLDataSources IN ODBC32.DLL ;
INTEGER henv, SHORT fdirection, ;
STRING @szDSN, INTEGER cbDSNMax, ;
INTEGER @pcbDSN, STRING @szDescription, ;
INTEGER cbDescriptionMax, INTEGER @pcbDescriptionn
hEnv = VAL(SYS(3053)) && The hEnv (converted to a number)
cbDsnMax = MAX_STRING && How long can the DSN Name be?
pcbDSN = 0 && How many were actually returned
cbDescriptMax = MAX_STRING && How long can the description be?
pcbDescript = 0 && How long the description actually was
fDirection = SQL_FETCH_FIRST && The first time start at the top
retVal = SQL_SUCCESS && Start with no errors
DO WHILE (retVal = SQL_SUCCESS)
szDsn = SPACE(MAX_STRING+1) && Make sure there is enough space
szDescript = SPACE(MAX_STRING+1)
retval = SQLDataSources(hEnv, fDirection, ;
@szDSN, cbDSNMax, @pcbDSN, ;
@szDescript, cbDescriptMax, @pcbDescript)
? LEFT(szDSN, pcbDSN)
? LEFT(szDescript, pcbDescript)
* We only want to do the SQL_FETCH_FIRST the first time
fDirection = SQL_FETCH_NEXT
ENDDO
Keywords: kbhowto kbinterop kbautomation KB155809