by Craig Sweet (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 31st August 2000
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Populate a ComboBox with the machine's current ODBC Data Source Names (DSNs).
API Declarations
Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)
Const SQL_SUCCESS As Long = 0
Const SQL_FETCH_NEXT As Long = 1
Dim i As Integer
Dim sDSNItem As String * 1024
Dim sDRVItem As String * 1024
Dim sDSN As String
Dim iDSNLen As Integer
Dim iDRVLen As Integer
Dim lHenv As Long 'handle to the environment
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)
sDSN = Left(sDSNItem, iDSNLen)
If sDSN <> Space(iDSNLen) Then
Box.AddItem sDSN
End If
Loop
Box.ListIndex = 0
End If
End Sub
Private Sub Form_Load()
Call GetDSNs(Combo1)
End Sub
No comments have been posted about Populate a ComboBox with the machine's current ODBC Data Source Names (DSNs).. Why not be the first to post a comment about Populate a ComboBox with the machine's current ODBC Data Source Names (DSNs)..