简体   繁体   English

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

[英]R with SQL server 2016 error “[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified”

I am trying to connect R with SQL server 2016, when I tried RevoScaleR_SqlServer_GettingStarted.R script or my own script I got the following error:我正在尝试将 R 与 SQL server 2016 连接,当我尝试RevoScaleR_SqlServer_GettingStarted.R脚本或我自己的脚本时,出现以下错误:

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ODBC Error in SQLDisconnect Could not open data source. [Microsoft][ODBC 驱动程序管理器] 未找到数据源名称且未指定默认驱动程序 SQLDisconnect 中的 ODBC 错误无法打开数据源。 Error in doTryCatch(return(expr), name, parentenv, handler) : Could not open data source. doTryCatch(return(expr), name, parentenv, handler) 中的错误:无法打开数据源。

Note: I can execute R script in SQL management studio.注意:我可以在 SQL management studio 中执行 R 脚本。 I already configured Microsoft ODBC Driver for SQL Server Version 13.00.1300 in ODBC Data Sources (64-bit).我已经在 ODBC 数据源(64 位)中为 SQL Server 版本 13.00.1300 配置了 Microsoft ODBC 驱动程序。

Ran into the same message... it looks like it is just a generic message from R that there is something wrong with your connection string.遇到相同的消息......看起来它只是来自 R 的一般消息,表明您的连接字符串有问题。

At least this was my issue... there was a space in the sample code where it wanted your server instance name.至少这是我的问题……示例代码中有一个空格,它需要您的服务器实例名称。 Deleting the space fixed it for me.删除空间为我修复了它。

# 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.

I just finished troubleshooting the same error message.我刚刚完成了对相同错误消息的故障排除。

"Data source name not found and no default driver specified" means that the dsn and driver need to be included in the connection details. “未找到数据源名称且未指定默认驱动程序”表示连接详细信息中需要包含 dsn 和驱动程序。

The following article from rstudio is helpful, and here's what worked for me: https://support.rstudio.com/hc/en-us/articles/214510788-Setting-up-R-to-connect-to-SQL-Server- rstudio 的以下文章很有帮助,这对我有用: https : //support.rstudio.com/hc/en-us/articles/214510788-Setting-up-R-to-connect-to-SQL-Server ——

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)

In addition to getting the connection correct, an ODBC Manager needs to be setup correctly and a driver that works with SQL Server needs to be chosen/installed.除了使连接正确之外,还需要正确设置 ODBC 管理器,并且需要选择/安装适用于 SQL Server 的驱动程序。

可能你应该在你的 r wd 中创建一个 txt 文件并将你的连接字符串保存在其中之后你应该使用 readLines("your connection string.txt") 来读取你的连接字符串并在你的代码中使用它为我工作...... ..仅供参考,您应该禁用具有高级安全性的Windows防火墙阻止R....

暂无
暂无

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

相关问题 从C#通过ODBC访问Sql Server:错误[IM002] [Microsoft] [ODBC驱动程序管理器]找不到数据源名称,并且未指定默认驱动程序 - Access to Sql Server via ODBC from C# : ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [Microsoft] [ODBC驱动程序管理器]找不到数据源名称,未指定默认驱动程序 - [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ODBC错误-找不到数据源名称,并且未指定默认驱动程序 - ODBC Error - Data source name not found and no default driver specified SQL Server-找不到数据源名称,也未指定默认驱动程序 - SQL Server - data source name not found and no default driver specified django.db.utils.InterfaceError:('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) ) - django.db.utils.InterfaceError:('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) ) 链接服务器“未找到数据源名称且未指定默认驱动程序”错误 - Linked server “Data source name not found and no default driver specified” error 错误:“OLE DB提供程序”MSDASQL“用于链接服务器”(null)“返回消息”[Microsoft] [ODBC驱动程序管理器]未找到数据源名称...“ - Error: “OLE DB provider ”MSDASQL“ for linked server ”(null)“ returned message ”[Microsoft][ODBC Driver Manager] Data source name not found …" SQL Server 连接错误 - 未找到数据源名称且未指定默认驱动程序 - SQL Server connection error - Data source name not found and no default driver specified 错误找不到数据源名称,并且在ADO.NET中没有使用Odbc指定默认驱动程序 - Error Data source name not found and no default driver specified with Odbc in ADO.NET 未找到数据源名称,且未指定默认驱动程序 - Data source name not found, and no default driver specified
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM