Reputation: 25
I want to add ODBC data source automatically using batch file. I tried this command but not succeeded.
ODBCCONF.exe /a {CONFIGSYSDSN "SQL Native Client" "DSN=VizdomDatabaseSource|Description=VizdomDatabaseSource|SERVER=%Server%|Trusted_Connection=Yes|Database=eee"}
Upvotes: 1
Views: 9214
Reputation: 51
This command worked for me
%windir%\syswow64\ODBCCONF.EXE configsysdsn "MySQL ODBC 8.0 Unicode Driver" "DSN=testodbcconfMySQL;SERVER=127.0.0.1;PORT=3306;DATABASE=sys;UID=YYY;password=XXX"
Upvotes: 0
Reputation: 11
odbcconf configdsn "SQL Server" "DSN={NAME}|Description={DESCRIPTION}|Server={SERVER}|Trusted_Connection={Yes/No}|Database={DATABASE}"
This will work every time on Windows 10. The Trusted_Connection
should be Yes
for Windows authentication or No
for SQL authentication. Everything else is rather straight forward. Do not add the {}
brackets, that is where you insert your custom fields.
Upvotes: 1
Reputation: 3591
You can do like this and run it with administrator rights
@echo off
set cn=%computername%
set host=%cn%\WINCC
ODBCCONF.EXE /a {CONFIGSYSDSN "SQL Native Client" "DSN=XY|Description=Descriptionname|SERVER=%host%|Trusted_Connection=Yes|Database=XY"}
echo SYSTEM DSN created successfuly...
pause
@CLS
@Exit
Upvotes: 1
Reputation: 46291
For 32-bit, execute the version in the SYSWOW64
directory:
%windir%\syswow64\ODBCCONF.EXE /a {CONFIGSYSDSN "SQL Native Client" "DSN=VizdomDatabaseSource|Description=VizdomDatabaseSource|SERVER=%Server%|Trusted_Connection=Yes|Database=eee"}
Upvotes: 3