简体   繁体   English

无法从R连接到Azure虚拟机数据库

[英]unable to connect to azure vm database from R

I am trying to connect to a Microsoft SQL Server database running on a virtual machine in Microsoft Azure, from R. 我正在尝试从R连接到在Microsoft Azure中的虚拟机上运行的Microsoft SQL Server数据库。

Here is what my SQL server looks like 这是我的SQL Server的样子 在此处输入图片说明

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? 为什么我不断收到此错误?

Try using the more flexible odbcDriverConnect function like this: 尝试使用更灵活的odbcDriverConnect函数,如下所示:

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: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM