2

I'm trying to connect to a MS SQL database via RODBC package. The following is not working :

ch = odbcDriverConnect(paste0("Driver=MSODBC;DSN=D.ad009.win.org;database=LCA;UID=LCA-User;PWD=xxxx"))

Warning messages:
1: In odbcDriverConnect(paste0("Driver=MSODBC;DSN=D.ad009.win.org;database=LCA;UID=LCA-User;PWD=xxxx")) :
  [RODBC] ERROR: state 08001, code 0, message [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Neither DSN nor SERVER keyword supplied
2: In odbcDriverConnect(paste0("Driver=MSODBC;DSN=D.ad009.win.org;database=LCA;UID=LCA-User;PWD=xxxx")) :
  ODBC connection failed

But changing the DSN to server will solve the problem :

ch = odbcDriverConnect(paste0("Driver=MSODBC;server=D.ad009.win.org;database=LCA;UID=LCA-User;PWD=xxxx"))

ch
RODBC Connection 8
Details:
  case=nochange
  DRIVER=MSODBC
  SERVER=D.ad009.win.org
  UID=LCA-User
  PWD=******
  WSID=d04x
  DATABASE=LCA

I was wondering what is the difference between DSN and server ???

Haribo
  • 2,071
  • 17
  • 37
  • A **DSN** is a data source name, a predefined server connection configuration. It typically includes one or more from: server (hostname/ipaddr), port, database name, user name, password, and encoding (among several). A **server** is just one component of that bigger configuration (hostname or ip address). [`odbc dsn`](https://www.google.com/search?q=odbc+dsn) suggested https://en.wikipedia.org/wiki/Data_source_name (among several). I had recommended you look for `/etc/odbc.ini` and/or `~/.odbc.ini`, did you find it? Does it include `[mydsn.net]` or `[D.ad009.win.org]`? – r2evans Oct 04 '20 at 04:39
  • @r2evans, I do not have access to that server ! It is an internal network server and I have just user / pass for the database itself. not the server. – Haribo Oct 04 '20 at 10:42
  • The server (in this context) is merely a hostname or an ip address ... if you cannot access the *server* or do not know its hostname or address, then you cannot access the database. This is a premise of networking: if you don't know where you need to go or don't have permission to go there, then you're not getting in. – r2evans Oct 04 '20 at 18:31

0 Answers0