user3349078
user3349078

Reputation: 23

classic asp TSQL no rowset returned

I have some TSQL used in classic asp like this:

Declare @tbl TABLE(some columns)
Declare @somevarables

Declare myCur CURSOR
For
    Select something From my_table
Open myCur

Fetch Next From myCur Inti somevarables
While (@@Fetch_Status<>-1)
  Begin
    some processimg
    ......
    Insert Into @tbl(...)
    Values(...)

    Fetch Next From myCur Inti somevarables
  End
Deallocate myCur

Select * From @tbl

The scripts worked well in SQL Query Analyzer. However, when I run it in an ASP page, there's no rowset returned, nor error message.

Who can tell me why?

Thanks!

Upvotes: 2

Views: 140

Answers (1)

user692942
user692942

Reputation: 16672

The problem is that you're inserting multiple times and each time your rows affected count will generate a closed recordset.

Simple fix is to make sure in your T-SQL you first SET NOCOUNT ON;, this will stop the row counts and the only recordset returned will be your end SELECT.

Upvotes: 1

Related Questions