|
Posted by Erland Sommarskog on 06/08/05 18:15
Jegg (jsauri@gmail.com) writes:
> I wrote a web app using an ASP front end (not .NET) connecting to a SQL
> Server 2000 (no SP) back end. Both the web server and the database
> server are Windows 2003 boxes. The app was running fine two weeks ago
> before I went on vacation. While I was gone my net admin applied
> Windows 2003 SP1 to the web server. Upon my return I was informed that
> the app is no longer working, getting the following error:
>
> [Microsoft][ODBC SQL Server Driver]Connection is busy with results for
> another hstmt
>
> Since that is presumably the only thing that changed in my absence I
> believe the SP somehow messed up the way the ODBC was working. I tried
> moving the SQL Server database to a different Windows 2003 box which
> also received the SP1 update and also includes SP3 for SQL Server, but
> get the same error.
>
> I am hitting the database like so:
>
> set GetData = CreateObject("ADODB.Command")
> GetData.ActiveConnection = SQLConn
> GetData.CommandText = "<stored procedure call>"
> Set DataRS= GetData.Execute (,,adCmdText)
>
> I appear to get the error when I execute the second call. I am
> learning ASP as I go, so maybe this is a trivial problem.
The gist of the error message is that you have a command that generated
one or more results, that you have not picked up, and you cannot submit
the next stored procedure for execution.
If that procedure generates result sets, you probably want that data.
Then again, it could be a stray debug result set that should not be
there.
Here are some general rules:
o Unless you want explicit row counts back from INSERT/UPDAET/DELETE
operations, submit a SET NOCOUNT ON when you connect. These rowcounts
are actually kind of result sets, and these need to be consumed.
SET NOCOUNT ON eliminates those.
o If you call a stored procedure that is not supposed to return data,
specify the option adExecuteNoRecords.
o When you run a procedure that can return data, be sure to get all
record sets, by looping over .NextRecordset.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Navigation:
[Reply to this message]
|