【问题标题】:Having trouble connecting R to SQL Server after sql server upgrade to TLS 1.2sql server 升级到 TLS 1.2 后将 R 连接到 SQL Server 时遇到问题
【发布时间】:2018-05-29 14:10:57
【问题描述】:

我一直用下面的代码成功连接R中的sql server

dbhandle=odbcDriverConnect("Driver={SQL Server};Server=servername;Database=databasename;Trusted_Connection=Yes")

但是,sql server 升级为兼容 TLS 1.2 后出现以下错误

Warning messages:
1: In odbcDriverConnect("Driver={SQL Server};Server=MHPOPMMSS100;Database=REZNKWB01;Trusted_Connection=Yes") :
  [RODBC] ERROR: state 08001, code 18, message [Microsoft][ODBC SQL Server Driver][DBNETLIB]SSL Security error
2: In odbcDriverConnect("Driver={SQL Server};Server=MHPOPMMSS100;Database=REZNKWB01;Trusted_Connection=Yes") :
  [RODBC] ERROR: state 01000, code 1, message [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (SECCreateCredentials()).
3: In odbcDriverConnect("Driver={SQL Server};Server=MHPOPMMSS100;Database=REZNKWB01;Trusted_Connection=Yes") :
  ODBC connection failed

我从来不需要 uid,但我尝试输入用于直接连接到 sql server 的相同用户 ID,我尝试过trustedconnection=yes 和否,我尝试在服务器之后添加端口,基本上任何我网上看过我试过了。

我想知道是否有我遗漏的东西或者是否有人有意见。谢谢!

【问题讨论】:

标签: r sql-server rodbc


【解决方案1】:
library(RODBC)
dbconnection <- odbcDriverConnect("Driver=ODBC Driver 11 for SQL Server;Server=Server_Name; Database=DB_Name;Uid=; Pwd=; trusted_connection=yes")
initdata <- sqlQuery(dbconnection,paste("select * from MyTable;"))
odbcClose(channel)

另外,请参阅下面的链接。

http://stackoverflow.com/questions/15420999/rodbc-odbcdriverconnect-connection-error

https://andersspur.wordpress.com/2013/11/26/connect-r-to-sql-server-2012-and-14/

最后,确保您的设置兼容 32 位或 64 位。在 SQL Server 中,执行以下操作:选择 @@Version

这将告诉您您使用的是 32 位还是 64 位。确保您的 R Studio 与您正在运行的任何版本的 SQL Server 兼容。

Note that by holding down the Control key during the launch of RStudio you can cause the R version selection dialog to display at startup.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-27
    • 2016-12-26
    • 1970-01-01
    • 1970-01-01
    • 2011-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多