Add ODBC data sources as script ? ODBC data source name alias ?

  • Hi,

    how can I script to add databases as ODBC data sources?

    would be convenient.

    2nd:

    Is it correct from what I see that I can have a database name only once in the ODBC catalog?

    Problem: having multiple systems (test/integration, produktion). when using the same database name in each of them, I actually cannot catalog two at the same time.

    Is that correct?

    What I am looking for would be something like an ODBC database alias or so ...

    Thanks,

    Juliane

  • You can open multiple Database connections in a procedure.

    Example

    Dim Cn as OneConnection

    Cn.connectionstring=..........

    Dim Cn2 as SecondConnection

    Cn2.ConnectionString

    Cn.execute Qry

    Cn2.execute qry.

    With this you can use multiple database without creating ODBC Connections !

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • Thanks,

    I will keep this in mind for the future.

    But I am afraid that does not help right now.

    The application itself is using tools based on ODBC and since I am not in a position to write tool extensions or Add-ins, no option for now.

  • for those interested in 2nd: a DB Alias can be given in the GUI by choosing a DSN Name of your choice: like DB_TEST and then selecting the database in "Change the default database name to" .

    I was thinking this is connected to the ID given on the page before, but of ourse that was not correct.

  • I may be mis-reading your question, so forgive me if I am. Are you asking how to script an ODBC DSN connection? A co-worker of mine was able to do this and make it part of an application installation. He created a file appname.reg which contained the following lines. If you use this, you just need to replace your values for DSNName, database name, server name, and login id:

    REGEDIT4

    [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\odbc.ini\DSNName]

    "Database"="database name"

    "Driver"="C:\\WINDOWS\\SYSTEM\\sqlsrv32.dll"

    "Description"="database name"

    "Server"="server name"

    "LastUser"="login id"

    [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\odbc.ini\ODBC Data Sources]

    "DSNName"="SQL Server"

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer]

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client]

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\DB-Lib]

    "AutoAnsiToOem"="ON"

    "UseIntlSettings"="ON"

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo]

    "DSQUERY"="DBMSSOCN"

    "server name"="DBMSSOCN,server name"

    If I need to set up the connection on someone's machine separate from the app, I just run this file.

    Hope this helps!

  • thank you laura.

    that is what I am looking for.

    I am not comfortable with editing the registry manually and I do not think it is good style, but seems I have to live with it.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply