I've set up my ODBC driver so that MS Excel can import the data into a spreadsheet just fine.
However, when I try to establish the connection with R, using
ch <- odbcConnect(leprosyDHISdb, uid = leprosyDHISid, pwd = leprosyDHISpw)
Then I get the error
Warning messages:
1: In odbcDriverConnect("DSN=dhis2;UID=dhis2_viewer;PWD=*********") :
[RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
2: In odbcDriverConnect("DSN=dhis2;UID=dhis2_viewer;PWD=*********") :
ODBC connection failed
What could make odbc fail for R, but not for Excel?
Strict compliance with Microsoft ODBC 3.52 Specification Our ODBC drivers provide full support for the standard Open Database Connectivity API functions and data types. ODBC interface allows Excel to connect to ODBC databases using the SQL language.
Connect to an ODBC data source from Power Query DesktopSelect the ODBC option in the Get Data selection. In From ODBC, select the data source name (DSN) from the Data source name (DSN) drop-down box. In this example, a DSN name of SQL Server Database was selected. Once you're done, select OK.
To update the ODBC driver Windows users can simply download and run the installer for the most current version. The installer will replace the existing ODBC driver installation on the system with the most current version. However, it isn't always practical to replace an entire installation.
Check if you are using a 32/64bit version of R, also check if your ODBC connection is 32/64bit.
To setup a 32bit DSN using windows navigate to the following folder C:\Windows\SysWOW64
To setup a 64bit DSN using windows navigate to the following folder C:\Windows\System32
EDIT: The following blog is an excellent guide you might find useful
http://sandymuspratt.blogspot.co.uk/2013/01/getting-access-data-into-r.html
I had the same issue recently. This is how I solved it:
1) Go to page: http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html and select the relevant OS and version to you.
2) Download the package using the link under "Instant Client Package - ODBC: Additional libraries for enabling ODBC applications"
3) Extract the files under C drive as C:\instantclient_12_1 and run odbc_install.exe in it.
4) Try connecting again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With