467,912 Members | 1,400 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,912 developers. It's quick & easy.

Viewing machine data source names

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

Aug 14 '06 #1
  • viewed: 2177
Share:
3 Replies

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.

Aug 14 '06 #2
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).GetValueNam es
If IsInList("FIL", valueNames, True) Then
Dim testVal As String =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(" SOFTWARE\ODBC\ODBC.INI").OpenSubKey(s).GetValue("F IL").ToString
End If
Next
End If

Thanks much,

zdrakec
za***@construction-imaging.com 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.
Aug 14 '06 #3

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).GetValueNam es
If IsInList("FIL", valueNames, True) Then
Dim testVal As String =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(" SOFTWARE\ODBC\ODBC.INI").OpenSubKey(s).GetValue("F IL").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.
za***@construction-imaging.com 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.
Aug 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Andrew Arace | last post: by
11 posts views Thread by Reshat Sabiq | last post: by
7 posts views Thread by D. Patrick | last post: by
reply views Thread by David P. Donahue | last post: by
3 posts views Thread by tom.youdan | last post: by
1 post views Thread by steven_nospam at Yahoo! Canada | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.