Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | kcrow@stata.com (Kevin H. Crow, StataCorp) |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: ODBC connection strings |
Date | Mon, 30 Sep 2013 16:33:44 -0500 |
Janet Hill <janethill73@yahoo.co.uk> wrote: >When I connect Stata to Access database I typically use statements of the form: > >odbc query "MS Access Database;DBQ=C:\Julie\Data September 2013.accdb;" > >or > >local dsn MS Access Database;DBQ=Data September 2013.accdb;DefaultDir=C:\Julie\; >odbc load, table("Demographics") dsn("`dsn'") clear allstring > >Recently my database administrator has told me that this approach is 'obsolete' >and that I should use connection strings. I have read Kevin Crow's article in >the Stata blog >http://blog.stata.com/2010/11/10/connection-string-support-added-to-odbc-command/ >and I have two questions: In your case there is no advantage to using the -connectionstring()- option. You don't really need to use the -connetionstring()- option for most -odbc- commands because -odbc- builds the connection string for you. It is not "obsolete" to use Stata's -odbc- command in the way you are using it. There are certain cases where a user may want to use certain options/features of a driver for a connection which are not available through the -odbc- command's other options, and this is where you use the -connectstring()- option. An example of the -connectionstring()- option would be . odbc query, connectionstring(`"Driver=Microsoft Access Driver (*.mdb, *.accdb) > ;DBQ=C:\Users\khc\Documents\Northwind.accdb"') DataSource: ConnectionString Path : C:\Users\khc\Documents\Northwind.accdb ------------------------------------------------------------------------ Customers Employee Privileges Employees Inventory Transaction Types Inventory Transactions Invoices Order Details Order Details Status Orders Orders Status Orders Tax Status Privileges Products Purchase Order Details Purchase Order Status Purchase Orders Sales Reports Shippers Strings Suppliers ------------------------------------------------------------------------- Kevin Crow StataCorp * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/