Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: ODBC connection strings


From   Janet Hill <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: ODBC connection strings
Date   Tue, 1 Oct 2013 10:41:23 +0100 (BST)

Kevin,
Thank you for both your explanation and the syntax.
Janet


----- Original Message -----
From: "Kevin H. Crow, StataCorp" <[email protected]>
To: [email protected]
Cc: 
Sent: Monday, 30 September 2013, 22:33
Subject: Re: st: ODBC connection strings

Janet Hill <[email protected]> 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?searchhttp://www.stata.com/support/faqs/resources/statalist-faq/http://www.ats.ucla.edu/stat/stata/


*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index