We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

How to create system DSN  using command line ?

OCUBE
OCUBE asked
on
Medium Priority
5,418 Views
Last Modified: 2012-05-06
How to create DSN on local pc (ODBC) using command line ?
Comment
Watch Question

Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015

Commented:
Only way I know of is to import registry keys (or use reg.exe, what is the cmdline equivalent). Best method is to create the DSN once (as a system DSN). and then export following keys:

HKLM\Software\ODBC\ODBC.Ini\ODBC Data Sources
HKLM\Software\ODBC\ODBC.ini\<<DSN-Name>>

That way you get all relevant settings. In the first export, you only need the line for the single DSN.

Either combine both edited exports to one reg file, and import it directly, or use reg import (whole file) or multiple reg add (single key).

Try this via batch file and/or run command. It will work for system DSN customize names and locations.

ODBCCONF.EXE /a {CONFIGSYSDSN "Microsoft Access Driver (*.mdb)" DSN=YourName;DBQ=\\yourserver\share\trackit.mdb;Description=YourName-Database;}

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Qlemo"Batchelor", Developer and EE Topic Advisor
CERTIFIED EXPERT
Top Expert 2015

Commented:
That is much better, but you need to know the complete driver name (should be easy, it's the same as shown when creating a DSN) and DSN string (can be obtained by looking to www.connectionstrings.com).
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.