Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ODBC connection?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00713618
Message ID:
00713778
Views:
15
Hi Selim,

Try this code:
LOCAL lihEnv,liDSN,liDescript,liDirection,liRet,lcDsn,lcDescript

DECLARE INTEGER SQLDataSources IN ODBC32.DLL ;
        INTEGER, SHORT , STRING @, INTEGER , ;
        INTEGER @, STRING @, INTEGER , INTEGER @

#DEFINE SQL_FETCH_NEXT 1
#DEFINE SQL_FETCH_FIRST 2
#DEFINE MAX_STRING 128
#DEFINE SQL_SUCCESS                0
#DEFINE SQL_SUCCESS_WITH_INFO      1
#DEFINE SQL_NO_DATA              100
#DEFINE SQL_ERROR                 (-1)
#DEFINE SQL_INVALID_HANDLE        (-2)

lihEnv = VAL(SYS(3053))      && The hEnv (converted to a number)
liDSN = 0                 && How many were actually returned
liDescript = 0            && How long the description actually was
liDirection = SQL_FETCH_FIRST     && The first time start at the top
liRet = SQL_SUCCESS             && Start with no errors
DO WHILE (INLIST(liRet,SQL_SUCCESS,SQL_SUCCESS_WITH_INFO))
   lcDsn = SPACE(MAX_STRING+1)   && Make sure there is enough space
   lcDescript = SPACE(MAX_STRING+1)

   liRet = SQLDataSources(lihEnv, liDirection, @lcDSN, MAX_STRING, @liDSN, ;
                           @lcDescript, MAX_STRING, @liDescript)

   IF liRet = SQL_SUCCESS
      ?LEFT(lcDSN, liDSN),LEFT(lcDescript, liDescript)
   ENDIF
   * We only want to do the SQL_FETCH_FIRST the first time
   liDirection = SQL_FETCH_NEXT
ENDDO
MartinJ

>I know how to create a odbc connection, I want to know if already exists becuase I don't want to create it again, and again, and again
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Previous
Reply
Map
View

Click here to load this message in the networking platform