将 activerecord-sqlserver-adapter 从 2.2.22 升级到 2.3.8,现在出现 ODBC 错误
我已经使用 MSSQL 2005 和 Rails 有一段时间了,决定在我的一个项目中提升我的能力,但遇到了一个问题。
我从 2.2.22 迁移到 2.3.8(截至撰写本文时的最新版本),突然我得到了这个:
ODBC::Error: S1090 (0) [unixODBC][Driver Manager]Invalid string or buffer length
我正在使用与 FreeTDS 的 DSN 连接,我的 database.yml
看起来像这样:
adapter: sqlserver
mode: ODBC
dsn: 'DRIVER=FreeTDS;TDSVER=7.0;SERVER=10.0.0.5;DATABASE=db;Port=1433;UID=user;PWD=pwd;'
现在与此同时,我回到了 2.2.22,没有弃用警告,一切看起来都很好,但显然为了保持最新状态,有什么想法可能会导致适配器发生变化吗?
I have been using MSSQL 2005 with Rails for quite a while now, and decided to bump my gems up on one of my projects and ran into a problem.
I moved from 2.2.22 to 2.3.8 (latest as of writing) and all of a sudden I got this:
ODBC::Error: S1090 (0) [unixODBC][Driver Manager]Invalid string or buffer length
I'm using a DSN connection with FreeTDS my database.yml
looks like this:
adapter: sqlserver
mode: ODBC
dsn: 'DRIVER=FreeTDS;TDSVER=7.0;SERVER=10.0.0.5;DATABASE=db;Port=1433;UID=user;PWD=pwd;'
Now in the mean time I moved back to 2.2.22 and there are no deprecation warnings and everything seems fine but obviously for the sake of being up to date, any ideas what could have changed in the adaptor that could cause this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该将 TinyTDS 与适配器一起使用,而不是 ODBC。即使在最新的 2.3 版本中,我也支持 TinyTDS。这是维基页面。
https://github.com/rails-sqlserver/activerecord-sqlserver -adapter/wiki/Using-TinyTds
TinyTDS 的好处是,它经过测试可以从 SQL Server 上的每种类型返回良好的数据,并且是 unicode 安全的。
You should use TinyTDS with the adapter, not ODBC. I have TinyTDS support even in the latest 2.3 versions. Here is the wiki page.
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds
The good thing about TinyTDS is that it is tested to return good data from every type on SQL Server and is unicode safe.
我刚刚遇到了类似的问题。删除 activerecord-sqlserver-adapter 并使用 activerecord-odbc-adapter(版本 2.0)。对我有用。
我刚刚卸载了 activerecord-sqlserver-adapter、dbi 和 dbd-odbc。然后安装了 activerecord-odbc-adapter 并将我的数据库配置更改为类似
Works sweet :)
I just had a similar problem. Removing the activerecord-sqlserver-adapter and using the activerecord-odbc-adapter (version 2.0). Works for me.
I just uninstalled activerecord-sqlserver-adapter, dbi, and dbd-odbc. And then installed activerecord-odbc-adapter and changed my db config to be something like
Works sweet : )