Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Array of current SQL connections?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00804170
Message ID:
00804190
Views:
33
This message has been marked as a message which has helped to the initial question of the thread.
AFAIK there is no such function. The fastest way I know is to issue a SQLSETPROP on a ReadOnly property and capture the error message. The following code executes quite fast:
LOCAL lcOldError, laHandles[1], lnHandles, lnI
PRIVATE plValid
plValid = .f.
lcOldError = ON('error')
ON ERROR GetError()
lnHandles = 0
FOR lnI = 1 to 255
    SQLSETPROP(lnI,"ConnectBusy",.t.)
    IF plValid
    	lnHandles = lnHandles + 1
    	DIMENSION laHandles[lnHandles]
    	laHandles[lnHandles] = lnI
    ENDIF
ENDFOR
ON ERROR &lcOldError
*!* do something with your laHandles array
SUSPEND
RETURN

PROCEDURE GetError
LOCAL lnError, laError[1]
AERROR(laError)
lnError = laError(1)
plValid = .f.
IF lnError = 1533  && "This property is read-only."
	plValid = .t.
ENDIF
*!*	Otherwise the error is 1466 "Connection handle is invalid."
>Hey all,
>
>For some reason I thought there was a function that would return an array of active SQL connection handles along with information about each connection. But I can't find anything in the docs in VFP 7.0 or 8.0...
>
>We have a function that checks for an existing connection, but it is slow in the event that no such connection exists (because it has to use SQLGETPROP() on all 255 possible handles to see if one exists). If there is a better way (such as the array I thought was available) it would be great to find something faster...
>
>Tell me what I'm missing, please! Thanks!
>
>JoeK
Mark McCasland
Midlothian, TX USA
Previous
Reply
Map
View

Click here to load this message in the networking platform