Const SQL_SUCCESS as Long = 0
Const SQL_FETCH_NEXT as Long = 1
'Sub GetDSNsAndDrivers()
Dim i as IntegerDim sDSNItem as string * 1024
Dim sDRVItem as string * 1024
Dim sDSN as string
Dim sDRV as string
Dim iDSNLen as IntegerDim iDRVLen as IntegerDim lHenv as Long'handle to the environment
on error resume next
cboDSNList.AddItem "(None)"
'get the DSNsIf SQLAllocEnv(lHenv) <> -1 then
DoUntil i <> SQL_SUCCESS
sDSNItem = Space$(1024)
sDRVItem = Space$(1024)
i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, _
iDSNLen, sDRVItem, 1024, iDRVLen)
sDSN = Left$(sDSNItem, iDSNLen)
sDRV = Left$(sDRVItem, iDRVLen)
If sDSN <> Space(iDSNLen) then
cboDSNList.AddItem sDSN
cboDrivers.AddItem sDRV '---optional - driver'--- value returnedEndIfLoopEndIf'remove the dupsIf cboDSNList.ListCount > 0 then
With cboDrivers
If .ListCount > 1 then
i = 0
While i < .ListCount
If .List(i) = .List(i + 1) then
.RemoveItem (i)
else
i = i + 1
EndIfWendEndIfEndWithEndIf
cboDSNList.ListIndex = 0
EndSub'
Add www.codeguru.com to your favorites Add www.codeguru.com to your browser search box IE 7 | Firefox 2.0 | Firefox 1.5.xReceive news via our XML/RSS feed