[英]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.