Hi,
I've got this code, which quite happily collects a list of DSN's from the PC, but I want to place this into a drop down list on an Access Form... Any ideas?
Thanks
Jamie
Private Declare Function SQLDataSources Lib "ODBC32.DLL" _
(ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, _
pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, _
pcbDescription%) As Integer
'
Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)
'
Dim SQL_SUCCESS As Long
Dim SQL_FETCH_NEXT As Long
Function GetDSNsAndDrivers()
SQL_FETCH_NEXT = 1
SQL_SUCCESS = 0
Dim i As Integer
Dim sDSNItem As String * 1024
Dim sDRVItem As String * 1024
Dim sDSN As String
Dim sDRV As String
Dim iDSNLen As Integer
Dim iDRVLen As Integer
Dim lHenv As Long 'handle to the environment
On Error Resume Next
cboDSNList.AddItem "(None)"
'get the DSNs
If SQLAllocEnv(lHenv) <> -1 Then
Do Until i <> SQL_SUCCESS
sDSNItem = Space$(1024)
sDRVItem = Space$(1024)
i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, _
iDSNLen, sDRVItem, 1024, iDRVLen)
If sDSN <> Space(iDSNLen) Then
cboDSNList.AddItem sDSN
End If
Loop
End If
End Function
I've got this code, which quite happily collects a list of DSN's from the PC, but I want to place this into a drop down list on an Access Form... Any ideas?
Thanks
Jamie
Private Declare Function SQLDataSources Lib "ODBC32.DLL" _
(ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, _
pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, _
pcbDescription%) As Integer
'
Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)
'
Dim SQL_SUCCESS As Long
Dim SQL_FETCH_NEXT As Long
Function GetDSNsAndDrivers()
SQL_FETCH_NEXT = 1
SQL_SUCCESS = 0
Dim i As Integer
Dim sDSNItem As String * 1024
Dim sDRVItem As String * 1024
Dim sDSN As String
Dim sDRV As String
Dim iDSNLen As Integer
Dim iDRVLen As Integer
Dim lHenv As Long 'handle to the environment
On Error Resume Next
cboDSNList.AddItem "(None)"
'get the DSNs
If SQLAllocEnv(lHenv) <> -1 Then
Do Until i <> SQL_SUCCESS
sDSNItem = Space$(1024)
sDRVItem = Space$(1024)
i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, _
iDSNLen, sDRVItem, 1024, iDRVLen)
If sDSN <> Space(iDSNLen) Then
cboDSNList.AddItem sDSN
End If
Loop
End If
End Function