简体   繁体   English

不使用DSN时出现R ODBC nanodbc错误

[英]R ODBC nanodbc error when not using DSN

Running into an issue between using the DSN versus non DSN with the R package ODBC. 在R包ODBC中使用DSN与非DSN之间遇到问题。

Using the DSN, I am successfully able to make a connection to the server and away the code goes. 使用DSN,我可以成功建立与服务器的连接,而无需编写代码。 However, using the non DSN odbc connection string, I am receiving: 但是,使用非DSN odbc连接字符串,我收到:

Error: nanodbc/nanodbc.cpp:950: IM002: [Microsoft][ODBC Driver Manager] Data >source name not found and no default driver specified 错误:nanodbc / nanodbc.cpp:950:IM002:[Microsoft] [ODBC驱动程序管理器]数据>源名称未找到,未指定默认驱动程序

The connection appears to be syntactically correct and all of the required fields are populated according to multiple function documentations, including: https://support.rstudio.com/hc/en-us/articles/214510788-Setting-up-R-to-connect-to-SQL-Server- 连接在语法上似乎正确,并且所有必填字段均根据多个功能文档进行了填充,其中包括: https : //support.rstudio.com/hc/zh-cn/articles/214510788-Setting-up-R-to -连接到SQL Server-

odbc_con <- dbConnect(odbc::odbc(),
                  Driver = "SQLServer",
                  Server = server,
                  Database = test, 
                  Uid = 'username',
                  Pwd = 'password',
                  Port = 1433)

Both server and test are defined earlier in the code. 服务器和测试都在代码的前面定义。 I have tried removing the odbc:: and just using odbc(). 我试过删除odbc ::,而仅使用odbc()。 Using semi-colons, removing caps. 使用分号删除盖子。

Bit stuck, any suggestions? 有点卡住,有什么建议吗?

When I switched from a Linux to a Windows box for R (note nothing else changed) I was getting 当我从Linux切换到Windows的R盒时(注意没有其他更改),我得到了

"Error: nanodbc/nanodbc.cpp:950: IM002: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified" 

The ODBC connection issue was fixed by changing 通过更改可解决ODBC连接问题

Driver = "ODBC Driver 17 for SQL Server"

to

Driver = "SQL Server"

Hope this saves you some time. 希望这可以节省您一些时间。

暂无
暂无

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

相关问题 R DBI ODBC 错误:nanodbc/nanodbc.cpp:3110:07009:[Microsoft][ODBC Driver 13 for Z9778840A0100CB30C982876741 - R DBI ODBC error: nanodbc/nanodbc.cpp:3110: 07009: [Microsoft][ODBC Driver 13 for SQL Server]Invalid Descriptor Index 无法将 Snowflake 连接到 R 错误:nanodbc/nanodbc.cpp:1021:00000:[Snowflake][ODBC] (11560) 无法找到 SQLGetPrivateProfileString function - Can't connect Snowflake to R Error: nanodbc/nanodbc.cpp:1021: 00000: [Snowflake][ODBC] (11560) Unable to locate SQLGetPrivateProfileString function R 中的 ODBC 连接字符串和/或 DSN - ODBC connection string and/or DSN in R 使用带有IP地址的新odbc软件包,不使用带有Oracle服务器的DSN - Using the new odbc package with an IP address and no DSN with an Oracle server 从 R 工作室连接到 SQL 服务器:“错误:nanodbc/nanodbc.cpp:983:00000: [unixODBC][Driver Manager]无法打开 lib 'driver': 找不到文件” - Connecting to SQL Server from R studios: "Error: nanodbc/nanodbc.cpp:983: 00000: [unixODBC][Driver Manager]Can't open lib 'driver' : file not found" 连接到 SQL Server 时如何使用 ODBC 解决 R 中的以下错误? - How to resolve the following error in R using ODBC when connecting to SQL Server? 使用ODBC从R查询SQL Server数据库时出现无效的对象名称时出错 - Invalid object name Error when querying SQL Server Database from R using ODBC ODBC 使用 R 连接 - ODBC Connection using R R Cassandra odbc错误 - R cassandra odbc error 当从批处理文件调用的脚本执行时,R 的 dbConnect 因“DSN 错误”而失败 - R's dbConnect fails with “DSN error” when executed by script called from batch file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM