Hi All,
How do I view the list of all db providers available on my machine using VB code?
Thanks in advance!
Binish
Printable View
Hi All,
How do I view the list of all db providers available on my machine using VB code?
Thanks in advance!
Binish
i hope from the registry you can read the details...
But could you suggest some VB code to do this?
TryVB Code:
Option Explicit Private Declare Function SQLDataSources% Lib "ODBC32.DLL" (ByVal henv&, _ ByVal fdir%, ByVal szDSN$, ByVal cbDSNMax%, pcbDSN%, ByVal szDesc$, _ ByVal cbDescMax%, pcbDesc%) Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&) Private Const SQL_SUCCESS As Long = 0 Private Const SQL_FETCH_NEXT As Long = 1 Private Sub Form_Load() Dim lngGetDBProviders As Long 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 lngGetDBProviders <> SQL_SUCCESS sDSNItem = Space(1024) sDRVItem = Space(1024) lngGetDBProviders = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, iDSNLen, sDRVItem, 1024, iDRVLen) sDSN = Left(sDSNItem, iDSNLen) If sDSN <> Space(iDSNLen) Then Combo1.AddItem sDSN End If Loop Combo1.ListIndex = 0 End If End Sub
That works. Thanks a lot!