Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to create System DSN with command prompt?

983 views
Skip to first unread message

Lei Yuan

unread,
Sep 23, 1999, 3:00:00 AM9/23/99
to
Does anybody how to create a System DSN from the command prompt of Windows
NT? I want to create it by running a batch file instead of from the GUI.

The executable file that I can use might be odbcconf.exe (after an
exhaustive search of the hard drive, it is the only relevant thing I
found) and the syntax is:
odbcconf <options> <command>

Does anybody know how to proceed? A detailed example will be the best, and
any input will be appreciated.

Thank you,

Lei

Mladen Turk

unread,
Sep 23, 1999, 3:00:00 AM9/23/99
to

Lei Yuan <ly...@chat.carleton.ca> wrote in message
news:7sd78h$287$1...@bertrand.ccs.carleton.ca...
The simplest way by the my opinion is to create the reg file with something
like that :

REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\odbc.ini\TestSQL]
"Server"="(local)"
"UseProcForPrepare"="Yes"
"Trusted_Connection"=""
"Description"=""

[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\odbc.ini\ODBC Data Sources]
"TestSQL"="SQL Server"

Name the file for examles testSQL.reg and from batch simply call that file

regsvr32 /s testSQL.reg


--
Mladen Turk, GISDATA d.o.o
MCSE/GIS Specialist
Bastijanova 52a, 10000 Zagreb, Croatia
mailto:mlade...@gisdata.hr
http://www.gisdata.com
http://www.gisdata.hr

Kris Koschik

unread,
Sep 23, 1999, 3:00:00 AM9/23/99
to
I agree with creating the .reg file. AlthoughThey have saved me hours of
work I have never run them from the command line. Here is how I did it:

Importing ODBC Settings Windows NT and Windows 95

1. Select Start…Run. Type ‘Regedit’
2. Select My Computer/HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/odbc.ini/ODBC DATA
SOURCES
3. Select Registry | Export Registry File
4. Type a name, save to a network if possible, and click ‘Save’
5. Edit the file you just saved (hold down Shift key, right-click Open
With...select NotePadUsing the current DSNs as a guide, create the one you
want.) Remove all other DSNs. The contents of the .reg file should appear as
such:


REGEDIT 4


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

"MyDataSourceName"="Sybase System 11"

6. Select any current the DSN. You use it as a template. Make sure it is SQL
Server DSN eg: My
Computer/HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/odbc.ini/MyCurrentDSN. Notice the
format on the right window pane.
7. Select Registry | Export Registry File
8. Save to a network if possible. Select all text in this file and ‘Cut’ and
‘Paste’ it to the end of the first file.
9. The final .reg file should look like this:

(this is the first part)
REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\odbc.ini\ODBC Data Sources]
"MyDSNName"="SQL Server"


(this is the second part)
REGEDIT4

[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\odbc.ini\MyDSNName]
"Driver"="C:\\WINDOWS\\SYSTEM\\sqlsrv32.dll"
"Description"="MyDatabase ON MyDSNName"
"Server"="MyServerName"
"UseProcForPrepare"="Yes"
"Database"="MyDatabase"
"OEMTOANSI"="Yes"
"Trusted_Connection"=""

10. To apply these ODBC settings simply double-click this file on another
computer and the data source settings should take place. Try to run it at
the command prompt.
11. Select Start…Settings…Control Panel…32BitODBC…System DSN tab. You should
see your Data Source in the list below. Select it, click ‘Configure’ to
verify the import was successful.

Mladen Turk wrote in message <7sdns1$pcg$1...@as102.tel.hr>...

Lei Yuan

unread,
Sep 29, 1999, 3:00:00 AM9/29/99
to
Thank you very much, Kris and Mladen, you helped me out.
BTW, I think the last thing to run should be:
regedit MYREG.reg

Lei

0 new messages