ohho ohho - 2 months ago 8
Ruby Question

tiny_tds failed at the second execute

Today, tiny_tds suddenly does not accept more than one

execute
and returns:

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


The code is simply as three
USE
s:

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")


Any clue what is the problem? I tried rebooting the Windows machine already.

Answer

You have to terminate the execute with a do:

Client.execute("...").do