Re: Viewing machine data source names




zdrakec wrote:
Thank you zacks:

As it turns out, yes, I had found a way in the manner you describe;
apparently, I needed to post the question before my brain would start
operating on it. I did:

Dim odbcNames() As String =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\ODBC\ODBC.INI").GetSubKeyNames
If Not odbcNames Is Nothing AndAlso odbcNames.Length > 0 Then
For Each s As String In odbcNames
Dim valueNames() As String =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\ODBC\ODBC.INI").OpenSubKey(s).GetValueNames
If IsInList("FIL", valueNames, True) Then
Dim testVal As String =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\ODBC\ODBC.INI").OpenSubKey(s).GetValue("FIL").ToString
End If
Next
End If

Thanks much,

zdrakec

Just remember that the "ODBS Data Sources" sub key is a special sub key
that does not define a DSN, but contains the current list of DSNs.

zacks@xxxxxxxxxxxxxxxxxxxxxxxx wrote:
zdrakec wrote:
Hello all:

I want to present my user with a list of all system data source names
(System DSN) that are defined on his machine that are of type MS Access
(.mdb). However, I am having some trouble figuring out how,
programatically, to get access to the ODBC data sources defined on the
user machine.
Can someone point me in the right direction?

Thanks much,
zdrakec

ODBC Data Sources are stored in the Registry. System DSNs are in
HKEY_LOCAL_MACHINE. User DSNs are stored in HKEY_CURRENT_USER (for each
user). From there they are in SOFTWARE\ODBC\ODBC.INI. Look in ODBC Data
Sources for the list, and each in the list will also have a key that
contains the contents of the DSN. Once you find them, it is pretty
obvious how they are stored. And as long as you are comfortable working
with the .NET Registry Class, it's a piece of cake working with them.

.



Relevant Pages

  • RE: Problem installing DBD::ODBC 1.13
    ... >data sources defined, yet it seems that you are using a DSN to connect. ... 5|gt250char|THIS IS A STRING LONGER THAN 80 CHARS. ... test connection success when DBI DSN is invalid ...
    (perl.dbi.users)
  • RE: Solution to Missing or Hidden System DSN
    ... Data Sources) can cause the same issue though. ... and some of its sub-keys contained an empty value for the REG_SZ, ... I'm pretty sure that if you created your DSN directly ... Start ODBC Data Source Administrator by typing "odbcad32.exe" in command ...
    (microsoft.public.data.odbc)
  • VS2008 on Vista x64: Applications cant see 32bit ODBC DSN but IDE
    ... psql-obdc v8.03.01 ... I created a System DSN using the Data Sources administration tool ...
    (microsoft.public.data.odbc)
  • RE: Solution to Missing or Hidden System DSN
    ... Data Sources) can cause the same issue though. ... and some of its sub-keys contained an empty value for the REG_SZ, ... I'm pretty sure that if you created your DSN directly ... in the registry, ...
    (microsoft.public.data.odbc)
  • Re: Viewing machine data source names
    ... zdrakec wrote: ... (System DSN) ... ODBC Data Sources are stored in the Registry. ...
    (microsoft.public.dotnet.languages.vb)

Quantcast