Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ADO Recordsets and Stored Procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-12-08 : 09:11:46
MikeG writes "I expereinced a 'problem' recently trying to return a resultset from a cursor in a SQL Server Stored Procedure. Given the following stored procedure :

CREATE PROCEDURE [RS_From_Cursor] AS
DECLARE @RecID DECIMAL
DECLARE @WhenCreated DATETIME
DECLARE @LastChanged DATETIME
DECLARE @SampleText VARCHAR(255)
DECLARE csr_sample CURSOR FOR
Select RecID, WhenCreated, LastChanged, SampleText from MJG_SAMPLE
OPEN csr_sample
FETCH NEXT FROM csr_sample
INTO @RecID, @WhenCreated, @LastChanged, @SampleText
WHILE @@FETCH_STATUS = 0
BEGIN
IF LEFT(@SampleText, 1) = 'H'
BEGIN
SELECT @RecID, @WhenCreated, @LastChanged, @SampleText
END

FETCH NEXT FROM csr_sample
INTO @RecID, @WhenCreated, @LastChanged, @SampleText
END
CLOSE csr_sample
DEALLOCATE csr_sample

when I look at the Fields collection in the ADO recordset, the field names are empty. In other words, if I look for rs("RecID") I get an empty string, if I look for rs(0) I get the expected value.

Is this by design or did I do something wrong?"
   

- Advertisement -