-- Declare local cursor to retrieve data from table CUSTOMERS
DECLARE cc CURSOR LOCAL FOR
SELECT CUSTOMER_ID, CUSTOMER_ADDRESS
FROM CUSTOMERS
FOR READ ONLY
OPEN cc
-- Loop and change all customer 5 addresses
WHILE 1 = 1 BEGIN
FETCH cc
INTO @customer_id, @customer_address
IF @@FETCH_STATUS <> 0 BREAK
IF @customer_id = 5 BEGIN
@customer_addresss = 'Newcastle'
END
INSERT INTO #CUSTOMERS (CUSTOMER_ID, CUSTOMER_ADDRESS)
VALUES @customer_id, @customer_address
END
SELECT * FROM #CUSTOMERS
CLOSE cc
DEALLOCATE cc
END
-------------------------------------------------------------------------------
I suspect that the object to retrieve the recordset from T-SQL stored procedure to VB code is closed. However I have already declare cursor cc as LOCAL. I suspect that the object is a global cursor and I have no idea why the it was closed. I suspect it has something to do with using cursor at the same time returning recordsets back to the VB code.
Could you please kindly advice me on how to solve this problem? Thank you very much in advance.
I didn't read that much the code... But aren't you forgetting to set the active connection to your command?
Emiliano F. Martín
If a post has helped you then pleaseRate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
I really don't know squat 'bout it. I would like to help you but have no clue what the problem could be. I don't know it the active connection was your problem or not. However, I use the idea of your T-SQL to make one of my own. I needed something like you did. Create a temporary table and change one field of all the records. I MADE IT It works great in the ISQL/w. However, I get the same error as you got. Just after the rs.open Statement, ADOConnection, the recordset appears to be closed.
If you found out what was going on, I would be glad to know your solution. Thanks in advance,
Emiliano F. Martín
If a post has helped you then pleaseRate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.