Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server R与SQL server 2016错误“;[Microsoft][ODBC驱动程序管理器]未找到数据源名称,未指定默认驱动程序;_Sql Server_R_Sql Server 2016_Revolution R - Fatal编程技术网

Sql server R与SQL server 2016错误“;[Microsoft][ODBC驱动程序管理器]未找到数据源名称,未指定默认驱动程序;

Sql server R与SQL server 2016错误“;[Microsoft][ODBC驱动程序管理器]未找到数据源名称,未指定默认驱动程序;,sql-server,r,sql-server-2016,revolution-r,Sql Server,R,Sql Server 2016,Revolution R,我正在尝试将R连接到SQL server 2016,当我尝试RevoScaleR\u SqlServer\u GettingStarted.R脚本或我自己的脚本时,我遇到以下错误: [Microsoft][ODBC驱动程序管理器]未找到数据源名称,也未指定默认驱动程序 SQLDisconnect中的ODBC错误 无法打开数据源。 doTryCatch中出错(返回(expr)、名称、parentenv、处理程序): 无法打开数据源 注意:我可以在SQL management studio中执行R脚

我正在尝试将R连接到SQL server 2016,当我尝试
RevoScaleR\u SqlServer\u GettingStarted.R
脚本或我自己的脚本时,我遇到以下错误:

[Microsoft][ODBC驱动程序管理器]未找到数据源名称,也未指定默认驱动程序 SQLDisconnect中的ODBC错误 无法打开数据源。 doTryCatch中出错(返回(expr)、名称、parentenv、处理程序): 无法打开数据源


注意:我可以在SQL management studio中执行R脚本。我已经在ODBC数据源(64位)中为SQL Server 13.00.1300版配置了Microsoft ODBC驱动程序。

您可能应该在r wd中创建一个txt文件,并在其中保存连接字符串,然后您应该使用readLines(“您的连接字符串.txt”)读取连接字符串 并在代码中使用它 为我工作。。。。。
仅供参考,您应该使用高级安全性禁用windows防火墙中的阻止R

遇到了相同的消息。。。看起来这只是来自R的一条通用消息,表明您的连接字符串有问题

至少这是我的问题。。。示例代码中有一个空格,它需要您的服务器实例名。删除空间为我修复了它

# https://microsoft.github.io/sql-ml-tutorials/R/customerclustering/step/2.html
#Connection string to connect to SQL Server. Don't forget to replace MyServer with the name of your SQL Server instance

connStr <- paste("Driver=SQL Server;Server=", " localhost", ";Database=" , "tpcxbb_1gb" , ";Trusted_Connection=true;" , sep="" ); # Broken... due to space in the paste.
connStr <- paste("Driver=SQL Server;Server=", "localhost", ";Database=" , "tpcxbb_1gb" , ";Trusted_Connection=true;" , sep="" ); #Fixed.
#https://microsoft.github.io/sql-ml-tutorials/R/customerclustering/step/2.html
#连接到SQL Server的连接字符串。不要忘记用SQL Server实例的名称替换MyServer

connStr我刚刚完成了对相同错误消息的故障排除

“未找到数据源名称且未指定默认驱动程序”表示dsn和驱动程序需要包含在连接详细信息中

rstudio的以下文章很有帮助,以下是对我有用的内容:

库(DBI)

con2有吗?您使用什么版本的R客户端连接到SQL Server?您是否试图从R客户端将计算推送到SQL Server 2016 R服务上?
library(DBI)
con2 <- dbConnect(odbc::odbc(),
                 .connection_string = "Driver={Simba SQL Server ODBC Driver};",
                 server= "<server>", 
                 dsn = "<data source name>",
                 database = "<database>",
                 uid = rstudioapi::askForPassword(prompt = 'Please enter username: '),
                 pwd = rstudioapi::askForPassword("Database password"),
                 timeout = 10,
                 trusted_connection = TRUE)