gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 08:26:50 24 4
gpt4 key购买 nike

在 R 包 ODBC 中使用 DSN 与非 DSN 之间遇到问题。

使用 DSN,我能够成功地连接到服务器并离开代码。但是,使用非 DSN odbc 连接字符串,我收到:

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

该连接在语法上似乎是正确的,并且所有必填字段均根据多个函数文档进行了填充,包括:https://support.rstudio.com/hc/en-us/articles/214510788-Setting-up-R-to-connect-to-SQL-Server-

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

服务器和测试都在代码的前面定义。我试过删除 odbc::并只使用 odbc()。使用分号,去掉大写字母。

有点卡住了,有什么建议吗?

最佳答案

当我从 Linux 切换到 R 的 Windows 机器时(注意没有其他改变)我得到了

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

ODBC 连接问题已通过更改修复

Driver = "ODBC Driver 17 for SQL Server"

Driver = "SQL Server"

希望这能为您节省一些时间。

关于不使用 DSN 时出现 R ODBC nanodbc 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50139986/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com