sql-server - tiny_tds 在第二次执行时失败

标签 sql-server ruby windows tiny-tds

今天,tiny_tds 突然不接受多个execute 并返回:

C:\>ruby test_use.rb
one
two
C:/test_use.rb:15:in `execute': Attempt to initiate a new Adaptive Server operation with results pending (TinyTds::Error)
    from C:/test_use.rb:15

代码就是三个USE:

require 'rubygems'
require 'yaml'
require 'fastercsv'
require 'tiny_tds'
require 'iconv'

CONFIG = YAML.load_file("config.yml")

client = TinyTds::Client.new(:username => CONFIG["db"]["username"], :password => CONFIG["db"]["password"], 
  :host => CONFIG["db"]["server"], :database => CONFIG["db"]["database"])

puts "one"
client.execute("USE DATAFEED")
puts "two"
client.execute("USE DATAFEED")
puts "three"
client.execute("USE DATAFEED")

有什么问题吗?我已经尝试重新启动 Windows 机器。

最佳答案

这是我如何做的一个例子。

results = $regcenter_db.execute("select top 10 * from events")
event_ids = results.collect { |i| i["event_id"] }
results.do    

关于sql-server - tiny_tds 在第二次执行时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7901306/

相关文章:

windows - 在 Windows 注册表中注册应用程序

sql-server - 在没有唯一约束的情况下确保不重复

SQL Server 连接 varchar 和 int

ruby - 在 Ruby 中组合 3 个并行数组的最佳和最快方法是什么

windows - 抑制 'Excel has stopped working' 对话框

java - 如何从命令行在 Windows 上运行 .class 文件?

sql-server - SQL Server 2005 :is it safe to use @@identity?

c# - SQL Server CE 在某些计算机上速度极慢

ruby - 在缓存中找不到元素 - 也许页面在 Selenium Ruby 网络驱动程序中查找后发生了变化?

ruby - 如何使用 Ruby 语言在不同的行中显示每个对象的属性以提高命令行的可读性?