Results 1 to 7 of 7

Thread: Find database path from ODBC

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    149

    Find database path from ODBC

    Hi,

    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.

    Thanks!

  2. #2
    Member
    Join Date
    Aug 2001
    Location
    Eugene, Oregon
    Posts
    41
    Well, you can have your program look in the registry. On my W2K install, it is located in:

    My Computer/HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBC.INI/dsnname/DBQ

    dsnname would be the name of your dsn

    let me know if you need help with the code to retreive values from the registry.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    149
    Yes, can you provide me with a simple example on how I can read the registry at this location. Thank a lot !

  4. #4
    Member
    Join Date
    Aug 2001
    Location
    Eugene, Oregon
    Posts
    41
    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.

    Let me know if you have any questions.
    Attached Files Attached Files

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    149
    Hi dhansen

    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 !

  6. #6
    Member
    Join Date
    Aug 2001
    Location
    Eugene, Oregon
    Posts
    41
    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.

  7. #7
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Originally posted by dollygoh
    Hi dhansen

    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.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width