Populate a ComboBox with the machine's current ODBC Data Source Names (DSNs).
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
Rate Populate a ComboBox with the machine's current ODBC Data Source Names (DSNs).
(1(1 Vote))
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
Populate a ComboBox with the machine's current ODBC Data Source Names (DSNs). Comments
No comments yet — be the first to post one!
Post a Comment