[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

dbd, ado, and ms sql server

jd33526@gmail.com

4/21/2006 11:40:00 PM

I get this error when I try to run the following code. Anyone have any
ideas why it's not working?

c:/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
transactionmode.
HRESULT error code:0x80020009
Exception occurred. from
c:/ruby/lib/ruby/site_ruby/1.8/dbi/dbi.rb:768:in `execute'
from test.rb:12

///////////////////////////////////////////////////////////////////
code
///////////////////////////////////////////////////////////////////

sth=dbh.prepare("select * from products where id = '38'")
sth.execute

while row=sth.fetch do
manf_id = row[5]

tmp = dbh.prepare("select * from manufacturers where id = " +
manf_id.to_s)
tmp.execute #this is the line that fails

end

14 Answers

rpardee@gmail.com

4/21/2006 11:51:00 PM

0

I think the issue is that the connection behind dbh is in a
spew-out-records mode & you've got to go through the whole return set
before it will be willing to do other work.

If you open a second connection, you should be able to use that to
..execute your inner select there.

Another option is to populate an array or hash w/your manf_id's in the
loop, and then loop through that separately.

HTH,

-Roy

jd33526@gmail.com

4/22/2006 12:24:00 AM

0

I tried two connections and got the same error. I could collect all the
rows first, but that seems like an ugly hack. I use ado with python and
it doesn't have this problem so I think there is something wrong with
the ruby implementation.

Also, I'm trying to use rails (activerecord) with sql server and am
getting a similar error. I dug into it a bit and I think that the error
i posted above with pure dbd is causing the rails error. This makes me
think that maybe I'm doing something wrong because I assume someone
else somewhere is using rails with sql server and not getting this
error.

rpardee@gmail.com

4/25/2006 9:47:00 PM

0

Hmmm... That's strange. FWIW--in the below, if I change the line that
assigns to stmt2 so that it's is .prepared by db1, I get the
transaction mode error you mention. As it is, it works.

require 'dbi'

CONNECTSTRING = "dbi:ADO:" +
"provider=SQLOLEDB.1;" +
"Integrated Security=SSPI;" +
"Persist Security Info=False;" +
"Initial Catalog=MENU;" +
"Data Source=."

ALTCONNECTSTRING = "dbi:ADO:" +
"provider=SQLOLEDB.1;" +
"Integrated Security=SSPI;" +
"Persist Security Info=False;" +
"Initial Catalog=MENU;" +
"Data Source=."

DBI.connect(CONNECTSTRING) do |db1|
db2 = DBI.connect(CONNECTSTRING)
stmt1 = db1.prepare("select * from statuses where status > ?")
stmt2 = db2.prepare("insert into drop_me (status) values (?)")
stmt1.execute(12)
stmt1.fetch do |row|
puts row[0]
stmt2.execute(row[0])
end
db2.commit
db2.disconnect
end

puts "finished!"

jd33526@gmail.com

4/25/2006 11:48:00 PM

0

Thanks for all the help Roy. I've sort of figured it out. Apparently
you *have* to iterate over the stmt2 or else you get the error I got
above. Now let's see if I can get rails working with ado and sql
server!

# connect to a datbase
db1 = DBI.connect(CONNECTSTRING)
db2 = DBI.connect(CONNECTSTRING)
stmt1 = db1.prepare("select top 5 * from products")

stmt1.execute
while row = stmt1.fetch do
puts row[0]
stmt2 = db2.prepare("select top 5 * from manufacturers")
stmt2.execute

#uncomment and error will go away
#stmt2.fetch do |row2|
# puts row2[0]
#end
end

db1.disconnect
db2.disconnect
gets

puts "finished!"

Robert Peffers

4/10/2011 10:58:00 PM

0


"Scotty" <spscot1@gmail.com> wrote in message
news:epa4q6pr0qe4sr5urq4rku1gj9ee0plm20@4ax.com...
> On Sun, 10 Apr 2011 21:24:52 +0100, Malcolm <Malcolm@indaal.demon.co.uk>
> wrote:
>
>>
>>I don't need any "luck" thank you. I'm a scientist with some knowledge
>>of genetics and therefore with the knowledge that there are no human
>>"races", whatever "white supremacists" such as yourself would like to
>>think.
>
> I'm not joining in here but if there are no races then why is the
> "offence"
> racism?
>
> Scott

Same reason there are no jays in jaywalking.


Akins of that Ilk

4/11/2011 1:17:00 AM

0

On Apr 10, 5:13 pm, Scotty <spsc...@gmail.com> wrote:
> On Sun, 10 Apr 2011 21:24:52 +0100, Malcolm <Malc...@indaal.demon.co.uk>
> wrote:
>
>
>
> >I don't need any "luck" thank you. I'm a scientist with some knowledge
> >of genetics and therefore with the knowledge that there are no human
> >"races", whatever "white supremacists" such as yourself would like to
> >think.
>
> I'm not joining in here but if there are no races then why is the "offence"
> racism?
>
> Scott

That does raise an interesting question, Malcolm....

Akins of that Ilk

4/11/2011 1:19:00 AM

0

On Apr 10, 3:39 pm, Fred J. McCall <fjmcc...@gmail.com> wrote:
> Akins of that Ilk <the_akins_of_ak...@yahoo.com> wrote:
>
> >On Apr 10, 1:22 pm, Fred J. McCall <fjmcc...@gmail.com> wrote:
>
> >> Puerile, Malcolm? You'll notice who Akins *prefers* to argue with.
> >> See what I mean about your 'approach'?
>
> >Fred, I've concluded that you just enjoy arguing for the entertainment
> >value of it. Malcolm on the other hand is a mindless tool of the ZOG.
>
> I don't 'argue' with you, Akins.  To do that I would have to seriously
> consider your bile.  It's far too stupid for that to happen.
>
> You'll keep failing and whinging about how it's not your fault but is
> a plot by all those 'inferior mud people' and I'll keep pointing out
> just how stupid someone has to be to believe what you believe.
>
> --
> "The supreme satisfaction is to be able to despise one s
>  neighbour and this fact goes far to account for religious
>  intolerance. It is evidently consoling to reflect that the
>  people next door are headed for hell."
>                                    -- Aleister Crowley

Fred, do you really want me to pull out the big list of Jews and post
it?

Fred J. McCall

4/11/2011 1:19:00 AM

0

Akins of that Ilk <the_akins_of_akins@yahoo.com> wrote:

>On Apr 10, 3:39?pm, Fred J. McCall <fjmcc...@gmail.com> wrote:
>> Akins of that Ilk <the_akins_of_ak...@yahoo.com> wrote:
>>
>> >On Apr 10, 1:22 pm, Fred J. McCall <fjmcc...@gmail.com> wrote:
>>
>> >> Puerile, Malcolm? You'll notice who Akins *prefers* to argue with.
>> >> See what I mean about your 'approach'?
>>
>> >Fred, I've concluded that you just enjoy arguing for the entertainment
>> >value of it. Malcolm on the other hand is a mindless tool of the ZOG.
>>
>> I don't 'argue' with you, Akins. ?To do that I would have to seriously
>> consider your bile. ?It's far too stupid for that to happen.
>>
>> You'll keep failing and whinging about how it's not your fault but is
>> a plot by all those 'inferior mud people' and I'll keep pointing out
>> just how stupid someone has to be to believe what you believe.
>>
>
>Fred, do you really want me to pull out the big list of Jews and post
>it?
>

And they're ALL kicking your ass insofar as being successful goes.
Yeah, you're a fine example of that 'superior White race' you're so on
about.

--
"The supreme satisfaction is to be able to despise one?s
neighbour and this fact goes far to account for religious
intolerance. It is evidently consoling to reflect that the
people next door are headed for hell."
-- Aleister Crowley

Malcolm

4/11/2011 6:43:00 AM

0


In article <epa4q6pr0qe4sr5urq4rku1gj9ee0plm20@4ax.com>, Scotty
<spscot1@gmail.com> writes
>On Sun, 10 Apr 2011 21:24:52 +0100, Malcolm <Malcolm@indaal.demon.co.uk>
>wrote:
>
>>
>>I don't need any "luck" thank you. I'm a scientist with some knowledge
>>of genetics and therefore with the knowledge that there are no human
>>"races", whatever "white supremacists" such as yourself would like to
>>think.
>
>I'm not joining in here but if there are no races then why is the "offence"
>racism?
>
Because there are those, like Akins "of that Ilk (sic)", who not only
think there are different races but regard themselves as superior to
other humans on this false basis. They would deny other people, who on
the whole don't look like themselves, the same rights and benefits that
they have. That denial, and other acts, is described as racism and is,
correctly, an offence in many countries, including the USA.

--
Malcolm

Malcolm

4/11/2011 6:47:00 AM

0


In article
<4ba411c8-6fa4-44c7-b197-4a8ebad9b7d2@32g2000vbe.googlegroups.com>,
Akins of that Ilk <the_akins_of_akins@yahoo.com> writes
>On Apr 10, 3:26?pm, Malcolm <Malc...@indaal.demon.co.uk> wrote:
>> In article
>> <dd2c4281-fc16-4135-8246-c174fb4b0...@l6g2000vbn.googlegroups.com>,
>> Akins of that Ilk <the_akins_of_ak...@yahoo.com> writes
>>
>> >On Apr 10, 1:22 pm, Fred J. McCall <fjmcc...@gmail.com> wrote:
>> >> Puerile, Malcolm? You'll notice who Akins *prefers* to argue with.
>> >> See what I mean about your 'approach'?
>>
>> >Fred, I've concluded that you just enjoy arguing for the entertainment
>> >value of it. Malcolm on the other hand is a mindless tool of the ZOG.
>>
>> As ever, Akins "of that Ilk (sic)" makes a wild assumption based on
>> prejudice and total ignorance.
>
>A bit like the argument that there are no physically defective people,
>they are just "differently abled"

That is a completely false analogy, as is only to be expected. That is
an example of a change in the use of language, originating in the US, as
an attempt to reduce denigratory and derogatory language about a
minority, and has nothing to do with your imaginary "ZOG".

--
Malcolm