question

Mansour Shoari avatar image
Mansour Shoari asked

Configuring an ODBC System DSN via CMD

Good day. Is there a way to configure an ODBC (System DSN) via CMD? If so, would there also be a way to test the connection (Test successful? Yes or No). I have a suite of custom applications that connect to a selected SQL servers using ODBC. There are many users in remote locations. It would be efficient to create a “.bat” and pack it with applications for the users to run and connect to the different data sources rather that configuring each in the GUI. Thank you.

odbc
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sp_lock avatar image
sp_lock answered
4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Fatherjack avatar image Fatherjack ♦♦ commented ·
great find but is the complete info anywhere? - I dont have a login to techtarget ...
0 Likes 0 ·
sp_lock avatar image sp_lock commented ·
@Fatherjack... If you scroll past the login and advert you will find the answers...
0 Likes 0 ·
Mansour Shoari avatar image Mansour Shoari commented ·
Great find, Jonlee. Thanks.
0 Likes 0 ·
Mansour Shoari avatar image Mansour Shoari commented ·
Fatherjack: On the CMD, if you type "odbcconf /?" It shows the complete usage with all the switches.
0 Likes 0 ·
Mansour Shoari avatar image
Mansour Shoari answered

I did a bit of reading on the subject and found a possible solution, so I am answering my own question: (i) Backup your registry. Again, backup your registry!(ii) Run > regedit (iii) search key under HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI for System DSN’s or HKEY_CURRENT_USER\Software\ODBC\ODBC.IN for user DSN’s (iv) RMC > Export (as e.g. MyODBCs.reg) (v) Copy one of ‘MyODBCs.reg’ DSN entries and paste at the end of the file and use it as a template to create additional DSNs (vi) Save MyODBCs.reg file (vii) Use regedit.exe to import MyODBCs.reg into the registry or double click on the file in Windows Explorer. This would modify the registry with amendments to the existing ODBC DSN’s. The '.reg' file can be placed in a .bat/.exe compilation file(s) with appropriate switches of regedit.exe and sent to users to run in their particular environments alongside application installation packages.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rasmithag avatar image
rasmithag answered
Syntax: odbcconf CONFIGSYSDSN " " "DSN= |SERVER=( )" ex:odbcconf CONFIGSYSDSN "Microsoft ODBC for Oracle" "DSN=Test1|SERVER=(server.world)" with this you can configure
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.