Reputation: 2144
I am trying to connect to a Microsoft SQL Server database running on a virtual machine in Microsoft Azure, from R.
Here is what my SQL server looks like
This is my connection string
library(RODBC)
channel = odbcConnect(dsn="something.cloudapp.net",uid="myusername",pwd="mypassword");
However, I keep getting this error
Warning messages:
1: In odbcDriverConnect("DSN=servername.cloudapp.net,1433;UID=myusername;PWD=mypassword") :
[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=servername.cloudapp.net,1433;UID=myusername;PWD=mypassword"):
ODBC connection failed
Why do I keep getting this error?
Upvotes: 2
Views: 522
Reputation: 141462
Try using the more flexible odbcDriverConnect
function like this:
odbcDriverConnect('driver={SQL Server};Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;')
Here it is with carriage returns for readability:
odbcDriverConnect(
'driver={SQL Server};
Server=myServerAddress;
Database=myDataBase;
User Id=myUsername;
Password=myPassword;')
See also:
Upvotes: 3