正文

ruby-dbi连sql server2007-03-28 11:30:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/daweizhao/24343.html

分享到:

已经困扰很久的问题,在网上查找,用别人的方法一路走下来,怎么都不行。go on.........

还是不行,上网看别人几乎也是这么做的,可是在自己这里却报错。郁闷

必须要做的要忙的事终于结束,可以有一段时间慢慢做自己想做的事了,呵呵,真好。公司位子新换了,挺兴奋的,呵呵。可以转头就看见外面蓝天了,呵呵。真好

似乎ruby的dbi连sql数据本身就有问题,在网上找到了东西如下:

There is something seriously wrong with DBI support for SQL server. I
have tried both DBI::ODBC and DBI:ADO and the following code always
fails.
---------- Code

require 'dbi'

host= "DEVELOPMENT_DATABASE_SERVER"
database="adventureworks2000"
username="someusername"
password="Somepwd"

db = DBI.connect("DBI:ADO:Provider=SQLOLEDB;Data
Source=#{host};Initial Catalog=#{database};User
Id=#{username};Password=#{password};")
sql= 'Select FirstName, LastName from contact'

sth = db.prepare(sql)
sth.execute

# Print out each row
while row=sth.fetch do
       p row
      db.do("select * from contact where 1 = 2")
end
 ---------------------
This is the error message you get.
D:/InstantRails/ruby/lib/ruby/site_ruby/1.8/DBD/ADO/ADO.rb:135:in
`execute': Execute (DBI::DatabaseError)
   OLE error code:80004005 in Microsoft OLE DB Provider for SQL Server
     Cannot create new connection because in manual or distributed
transaction mode.
   HRESULT error code:0x80020009




The db.do statement always fails no matter what the query is. The
driver refuses to run more then one query at a time even if the query
does not return records.

I have seen other people report this problem because it seems to be
happening frequently in rails apps when the concurrency goes up.

Anyway at this stage it seems like DBI support for SQL server is
minimal at best.

链接也放上:http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/211423
这个问题先放置一下,已经看了好久了,也没有解决问题。先看看别的基础的再说。
再附上一个ruby的dbi使用的链接:http://blog.csdn.net/zshwlw/archive/2006/12/02/1426117.aspx

阅读(4844) | 评论(1)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册