dragonchild is correct.

Funny thing is I was just reading about this last night in my "Programming the Perl DBI" book. It says if a statement handle is opened and has not been "finished" you will get the following warning when trying to reuse the statement handle: "disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting)". If you are fetching from a statement handle and you fetch the last row, the finish method is called for you. On the other hand if you do not fetch all the rows and try to reuse the statement handle you get the following warning: "disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting)".

What I didn't read in the book is this. If you attempt to reuse the database handle when a statement handle is open and not finished you get the error: "st execute failed: [Microsoft][ODBC SQL Server Driver]Connection is busy with results for another hstmt". This may only be the case with MS SQL, but I am not sure.

When I executed equivalent code you posted with warnings turned on, I got both the error you posted and the warning I posted.

Update: Put code tags around error message to fix output.


In reply to Re^2: MS SQL problem by disciple
in thread MS SQL problem by Win

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.