I have an stored procedure that declares a Table variable, opens a cursor and feeds with it the table variable and then returns a result set from the table variable to the client.

-- Table variable declaration and cursors declaration
declare @MyTable as Table (....)
declare CursorForAnotherTable cursor for select * from AnotherTable
declare @OtherVariables ...

-- Feed the Table Variable
open CursorForAnotherTable
fetch CursorForAnotherTable into ...
while @@Fetch_Status=0
insert into @MyTable values (...)
fetch CursorForAnotherTable into ...

close CursorForAnotherTable
deallocate CursorForAnotherTable

-- Return the result set
select * from @MyTable

The procedure executes as expected when called from the Query Analizer, but when using ADO in a Visual Basic application, the recordset does not open. I assure that the code used works just fine with other stored procedures.

What could be wrong?

Thanks a lot in advance.