|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Viewing machine data source namesHello 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 zdrakec wrote:
> Hello all: ODBC Data Sources are stored in the Registry. System DSNs are in> > 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 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. 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 za***@construction-imaging.com wrote: Show quoteHide quote > 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. zdrakec wrote:
Show quoteHide quote > Thank you zacks: Just remember that the "ODBS Data Sources" sub key is a special sub key> > 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 that does not define a DSN, but contains the current list of DSNs. Show quoteHide quote > 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.
Active Directory
Populating date into SQL Option strict question. How to mask console password input Compiling list of items that WinForms can do, WebForms cannot Creating Reports from SQL data Waiting for com program to terminate what have they done to the left function how to format text for email message Filename from Open With |
|||||||||||||||||||||||