Announcement

Collapse
No announcement yet.

Enumerating DSNs

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Enumerating DSNs

    All,

    I was wondering if anyone knows how to enumerate the DSNs on a machine.

    Thanks,

    Rich

    ------------------
    _____________________________________________________________________________________
    It's hard when you're up to your armpits in alligators to remember you came here to drain the swamp.
    President Reagan
    February 10, 1982

  • #2
    If using odbc32, I use this function:-

    FUNCTION XGetDataSources( Res() AS ASCIIZ * 64, nElems AS LONG) AS LONG

    DIM DataSource AS ASCIIZ * 64, Description AS ASCIIZ * 256, Rec$
    DIM DataSourceLen AS INTEGER, DescriptionLen AS INTEGER
    DIM RetCode AS INTEGER, DataSourcePTR AS STRING PTR, _
    DescriptionPTR AS STRING PTR, RecNum AS LONG

    DataSourceLen = 63 'len(DataSource) - 1
    DescriptionLen = 255 'Len(Description) - 1

    RetCode = SQLDataSources(henv, _
    2, _
    DataSource, _
    63, _
    63, _
    Description, _
    255, _
    255)

    DO
    IF (RetCode < 0 OR RetCode > 1) THEN EXIT DO

    Rec$ = TRIM$(MID$(DataSource,1,DataSourceLen))

    RecNum = RecNum + 1

    IF RecNum > nElems THEN
    nElems = nElems + 50
    REDIM PRESERVE res(1 TO nElems)
    END IF

    Res(RecNum) = Rec

    Rec = ""


    RetCode = SQLDataSources(henv, _
    1, _
    DataSource, _
    63, _
    63, _
    Description, _
    255, _
    255)
    LOOP

    FUNCTION = RecNum

    END FUNCTION


    ------------------

    Comment


    • #3
      David,

      Thanks, I appreciate your help.


      Rich

      ------------------
      _____________________________________________________________________________________
      It's hard when you're up to your armpits in alligators to remember you came here to drain the swamp.
      President Reagan
      February 10, 1982

      Comment

      Working...
      X