Benzle Benzle - 6 days ago 5
R Question

New to ODBC in R (RStudio), and getting a failed to connect error?

Working through a tutorial to pull database data with:

install.packages('RODBC')
require(RODBC)

myNewDB=odbcConnect("QV Training")


And I get the error:



In odbcDriverConnect("DSN=QV Training")
Data source name not found and no default driver specified
In odbcDriverConnect("DSN=QV Training") : ODBC connection failed



Is 'QV Training' meant to be the name of a database that may no longer be present?

How does R know where to look for the database anyway?

Thank you!

Answer

In Windows (unsure of other OSes) you need to go into the ODBC Data source Administrator, and add the data source.

ODBC data source administrator panel create new data source panel create a new data source to sql server panel

The connection command is then simply

conn <- odbcConnect("QV Training")