Is it possible to retrieve the path of the database through the
DSN created using ODBC, without having to open a connection ?
I am using Access database.
There are a couple ways to get/save values in the registry. The easiest one is using the "GetSetting" and "SaveSetting" functions built into Visual Basic. If you do a search for them on this board, you will find many examples. The only thing is, those functions are limited as to the part of the registry they can access.
Another way is using some API's. There is a prebuilt library for this that comes with Visual Basic. I have attached a VB file that has that library as a module and then a sample form to show you how to use it.
I have run your attachment but the path of the database is not retrieve. Actually, I don't really need to save the registry so I tried to use GetSetting but it can't work. In which parameter of the GetSetting function can I placed the path :
MyComputer/HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBC.INI/dsnname/DBQ ?
Will the path in the registry still remain the same if I using different window operating system ?
The path in the registry is actually for DSN created in the system or user dsn ? Thanks !
The example was for a system dsn with either Windows 2000 or Windows XP Pro. Those are the two systems I tested on.
The attachment I sent works on my system to get the db path on the two systems I mentioned above. Check out my profile and send me an ICQ (number is in profile) and I can try to help further.
I have run your attachment but the path of the database is not retrieve. Actually, I don't really need to save the registry so I tried to use GetSetting but it can't work. In which parameter of the GetSetting function can I placed the path :
MyComputer/HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBC.INI/dsnname/DBQ ?
Will the path in the registry still remain the same if I using different window operating system ?
The path in the registry is actually for DSN created in the system or user dsn ? Thanks !
Are you trying to use the VB function GetSetting. It won't work in this case.
You will need to use API functions to access registry. See if this class is of any help to you.
And remember not to include MY Computer at the start.