Results 1 to 4 of 4

Thread: List all system DSN's

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2001
    Posts
    44

    Question

    Hi,

    How can i list all the system DSN's to check if a specific one is configured?

    Thanks.

    João Pinto

  2. #2
    Hyperactive Member SoftwareMaker's Avatar
    Join Date
    Mar 2001
    Location
    Elbonia with Dilbert and Wally
    Posts
    322

    Hi

    I am not sure I understand your Question.

    Are you referring to the ODBC System DSN or a WebServer DSN ?

    I could give you some tips on the ODBC System DSN but I know NOTHING about the WebServer DSN
    William T
    Software Architect / Chief Software Developer
    Softwaremaker.Net Pte Ltd
    http://www.Softwaremaker.net

    *** Things are always the darkest before they go pitch black ***

  3. #3
    Lively Member
    Join Date
    Mar 2001
    Location
    India
    Posts
    81
    Hi,

    The following code puts all the DSN into a combo box. Hope this helps

    Sub GetDSNsAndDrivers()
    'this returns all the DSN names present
    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)
    sDSN = Left$(sDSNItem, iDSNLen)
    sDRV = Left$(sDRVItem, iDRVLen)

    If sDSN <> Space(iDSNLen) Then
    cboDSNList.AddItem sDSN
    End If
    Loop
    End If
    cboDSNList.ListIndex = 0
    End Sub

    Add this in the Gen Decl

    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&)

    Const SQL_SUCCESS As Long = 0

    Const SQL_FETCH_NEXT As Long = 1


    Pls reply ASAP.

    Luv...........Ravindran

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2001
    Posts
    44
    Thanks ravindran_b.

    It's already working.

    By the way check this URL to see if you have a solution.

    Thanks again.

    João Pinto

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width