Creating a DSN for Access from the command line

G

Guest

I want to create a system or user DSN for an Access database without having to go through the wizard available in the ODBC Data Source Administrator tool (in the Start->Control Panel->Administrative Tools->Data Sources)

I went through the discussions regarding this and found ways to do this for setting up DSNs for SQL Server or MySql using the odbcconf command (code snippets are attached below). Following the SQL Server example, I can set up a DSN using the command

odbcconf configsysdsn "Microsoft Access Driver (*.mdb)" "DSN=Test_DSN

But I am not able to select or create a .mdb file that is associated with this DSN. I still have to go to the Data Source Administrator tool to associate a mdb file with the DSN. Is there any way I can supply more data to the odbcconf command to select or create a new .mdb file for the DSN

Thanks.

-kesha

SQL Server -
odbcconf configsysdsn "SQL Server" "DSN=test1|SERVER=(local)

For MySql - use the odbcconf command with a config file in this wa
"odbcconf /f myodbc.rsp

where the myodbc.rsp file contains the followin

INSTALLDRIVER "MySQL Driver|Driver=myodbc.dll|Setup=myodbc.dll||
CONFIGDRIVER "MySQL Driver" "APILevel=2
CONFIGDRIVER "MySQL Driver" "ConnectFunctions=YYN
CONFIGDRIVER "MySQL Driver" "DriverODBCVer=2.50.40
CONFIGDRIVER "MySQL Driver" "FileUsage=0
CONFIGDRIVER "MySQL Driver" "FileExtns=*.txt
CONFIGDRIVER "MySQL Driver" "SQLLevel=1
CONFIGDRIVER "MySQL Driver" "CPTimeout=60
CONFIGDSN "MySQL Driver" "DSN=sample-MySQL;Description=MySQL ODB
Driver;SERVER=database_server;User=odbc;DB=test;Port=3306||"
 
T

Tony Toews

keshav said:
I want to create a system or user DSN for an Access database without having to go through the wizard available in the ODBC Data Source Administrator tool (in the Start->Control Panel->Administrative Tools->Data Sources).

My first reaction would be to not use DSNs at all.

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
ODBC DSN-Less Connection Tutorial Part I
http://www.amazecreations.com/datafast/GetFile.aspx?file=ODBCTutor01.htm&Article=true
HOWTO: Use "DSN-Less" ODBC Connections with RDO and DAO
http://support.microsoft.com/?id=147875
ODBC DSN Less
http://www.able-consulting.com/MDAC/ADO/Connection/ODBC_DSNLess.htm

Tony
 
T

Tony Toews

keshav said:
I need to have the DSN for my Java program to connect to the database through JDBC and currently I have to go and set up the DSNs on every machine I want to run the java program. So having an easy way to create a DSN would help a lot.

Excellent reason then. <smile>

I have seen code on how to create DSNs but I never recorded any
details.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top