Jamsheed Saeed
Jamsheed Saeed

Reputation: 25

How to add system DSN into odbc 32-bit using bat file?

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

Answers (4)

suchintya
suchintya

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

Cbacon21
Cbacon21

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

SqlKindaGuy
SqlKindaGuy

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

Dan Guzman
Dan Guzman

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

Related Questions