已经困扰很久的问题,在网上查找,用别人的方法一路走下来,怎么都不行。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
评论