我正在尝试连接到在Microsoft Azure中的虚拟机上运行的Microsoft SQL Server数据库,来自R.
这是我的连接字符串
library(RODBC)
channel = odbcConnect(dsn="something.cloudapp.net",uid="myusername",pwd="mypassword");
但是,我一直收到此错误
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
为什么我一直收到此错误?
答案 0 :(得分:3)
尝试使用更灵活的odbcDriverConnect
功能,如下所示:
odbcDriverConnect('driver={SQL Server};Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;')
为了便于阅读,这里有回车符:
odbcDriverConnect(
'driver={SQL Server};
Server=myServerAddress;
Database=myDataBase;
User Id=myUsername;
Password=myPassword;')
另见: