Creating ODBC DSN's

  • Thread starter Thread starter S_Troker
  • Start date Start date
S

S_Troker

Is it possible to create a SQL server ODBC DSN successfully by using a
script????

anyone know of any tools maybe, if scripting is not an option.

I know its not a huge job to create a DSN manually, but after doing quite a
few machines at once, one begins to think that double clicking an icon may
be a bit easier..

I guess the script might ask for a server and database name or somehow
accomadate that functionality.
 
I use this in Access. Not a nice formatted function, but I hope it is
clear enough.

Variables:
Public Const csDatabase = "SQL_database"
Public Const csDSN = "DSN_name"
Public Const csODBCConnect =
"ODBC;DATABASE=SQL_database;DSN=DSN_name;Trusted_Connection=No;UID=SQL_username;PWD=SQL_password"

Command (should all be on 1 line):
DBEngine.RegisterDatabase csDSN, "SQL Server", True, "Description=" &
sDatabase & Chr(13) & "Server=" & csServer & Chr(13) & "Database=" &
csDatabase & Chr(13) & "Trusted_Connection=No" & Chr(13) &
"NETWORK=DBMSSOCN"

Replace SQL_database and DSN_name with your values. The connectstring
in this example is for SQL server login. If you use Windows login,
just set Trusted_Connection=Yes. Of course you can write a nice
function with parameters for the variables if desired.

Hope this helps.
Wilfred
 
S_Troker said:
Is it possible to create a SQL server ODBC DSN successfully by using a
script????

I'd definitely go with Danny's suggestion of not using DSNs. Standard
blurb follows.

I much prefer DSN-Less connections as it is one less thing for someone
to have to configure and one less thing for the users to screw up.

Using DSN-Less Connections
http://members.rogers.com/douglas.j.steele/DSNLessLinks.html
HOWTO: Use "DSN-Less" ODBC Connections with RDO and DAO
http://support.microsoft.com/?id=147875

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
Back
Top