Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 52801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:57:49+00:00 2026-05-10T16:57:49+00:00

I have an Excel application in which I want to present the user with

  • 0

I have an Excel application in which I want to present the user with a list of the Data Source Names (ie: DSN’s), whereby s/he can choose what data source to use.

Hopefully once I’ve got the list, I can easily access the DSN properties to connect to the appropriate database.

Please note, I do not want to use a DSN-less connection.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T16:57:50+00:00Added an answer on May 10, 2026 at 4:57 pm

    The DSN entries are stored in the registry in the following keys.

    HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources

    This contains the list of all defined DSN. This acts as an global index and the specific details for each DSN are stored in a key with the DSN name under:

    HKEY_CURRENT_USER\Software\ODBC\ODBC.INI HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI

    Create some entries in both User DSN and System DSN tabs from Data Sources (ODBC) control panel applet and check how these values are stored in the registry.

    The following example enumerate the DSN defined for the user trough Control Panel > Administrative Tools > Data Sources (ODBC) [User Dsn Tab].

    http://support.microsoft.com/kb/178755

      Option Explicit    Private Declare Function RegOpenKeyEx Lib 'advapi32.dll' _       Alias 'RegOpenKeyExA' _       (ByVal hKey As Long, _       ByVal lpSubKey As String, _       ByVal ulOptions As Long, _       ByVal samDesired As Long, phkResult As Long) As Long    Private Declare Function RegEnumValue Lib 'advapi32.dll' _       Alias 'RegEnumValueA' _       (ByVal hKey As Long, _       ByVal dwIndex As Long, _       ByVal lpValueName As String, _       lpcbValueName As Long, _       ByVal lpReserved As Long, _       lpType As Long, _       lpData As Any, _       lpcbData As Long) As Long    Private Declare Function RegCloseKey Lib 'advapi32.dll' _       (ByVal hKey As Long) As Long    Const HKEY_CLASSES_ROOT = &H80000000   Const HKEY_CURRENT_USER = &H80000001   Const HKEY_LOCAL_MACHINE = &H80000002   Const HKEY_USERS = &H80000003    Const ERROR_SUCCESS = 0&    Const SYNCHRONIZE = &H100000   Const STANDARD_RIGHTS_READ = &H20000   Const STANDARD_RIGHTS_WRITE = &H20000   Const STANDARD_RIGHTS_EXECUTE = &H20000   Const STANDARD_RIGHTS_REQUIRED = &HF0000   Const STANDARD_RIGHTS_ALL = &H1F0000   Const KEY_QUERY_VALUE = &H1   Const KEY_SET_VALUE = &H2   Const KEY_CREATE_SUB_KEY = &H4   Const KEY_ENUMERATE_SUB_KEYS = &H8   Const KEY_NOTIFY = &H10   Const KEY_CREATE_LINK = &H20   Const KEY_READ = ((STANDARD_RIGHTS_READ Or _                     KEY_QUERY_VALUE Or _                     KEY_ENUMERATE_SUB_KEYS Or _                     KEY_NOTIFY) And _                     (Not SYNCHRONIZE))    Const REG_DWORD = 4   Const REG_BINARY = 3   Const REG_SZ = 1    Private Sub Command1_Click()      Dim lngKeyHandle As Long      Dim lngResult As Long      Dim lngCurIdx As Long      Dim strValue As String      Dim lngValueLen As Long      Dim lngData As Long      Dim lngDataLen As Long      Dim strResult As String       lngResult = RegOpenKeyEx(HKEY_CURRENT_USER, _              'SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources', _               0&, _               KEY_READ, _               lngKeyHandle)       If lngResult <> ERROR_SUCCESS Then          MsgBox 'Cannot open key'          Exit Sub      End If       lngCurIdx = 0      Do         lngValueLen = 2000         strValue = String(lngValueLen, 0)         lngDataLen = 2000          lngResult = RegEnumValue(lngKeyHandle, _                                  lngCurIdx, _                                  ByVal strValue, _                                  lngValueLen, _                                  0&, _                                  REG_DWORD, _                                  ByVal lngData, _                                  lngDataLen)         lngCurIdx = lngCurIdx + 1          If lngResult = ERROR_SUCCESS Then            strResult = strResult & lngCurIdx & ': ' & Left(strValue, lngValueLen) & vbCrLf         End If      Loop While lngResult = ERROR_SUCCESS      Call RegCloseKey(lngKeyHandle)       Call MsgBox(strResult, vbInformation)   End Sub 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 58k
  • Answers 58k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You'd need to design your installation such that it doesn't… May 11, 2026 at 8:44 am
  • added an answer I'm the author of the CPAN module CAM::PDF which is… May 11, 2026 at 8:44 am
  • added an answer No, it's not impossible, but Erlang does make it much… May 11, 2026 at 8:44 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.