#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2009
    Posts
    56
    Rep Power
    5

    User chooses ODBC connection


    I am new to Visual Basic and was after some information.
    I have a menu item in my VB Form which launches the ODBCAD32.exe program.
    Code:
    Process.Start(Environment.SystemDirectory + "\odbcad32.exe")
    I then let the user choose the DSN name of the database. Is it possible to return this value to VB to create the connection within VB?

    Thanks
    itrs
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    289
    Rep Power
    44
    There is no need to use the ODBC Manager at all, as the information is available from the registry. System DNS's are listed in:
    HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI
    and user DSN's are listed in:
    KEY_CURRENT_USER\Software\ODBC\ODBC.INI

    For sample code on how to use this information in 32 bit and 64 bit systems, see:

    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=74519&lngWId=1

    J.A. Coutts
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2009
    Posts
    56
    Rep Power
    5
    Originally Posted by couttsj
    There is no need to use the ODBC Manager at all, as the information is available from the registry. System DNS's are listed in:
    HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI
    and user DSN's are listed in:
    KEY_CURRENT_USER\Software\ODBC\ODBC.INI

    For sample code on how to use this information in 32 bit and 64 bit systems, see:

    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=74519&lngWId=1

    J.A. Coutts
    Thanks couttsj,

    That is for VB6 and I am using 2010. I will take a look.
    What I am after is letting the user choose a database and server and storing that information in a configuration file for future use. I thought choosing and ODBC would be easier.
    Any other ideas?

IMN logo majestic logo threadwatch logo seochat tools logo