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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-01-14 : 23:42:53
|
Rob writes "I am trying to run the following stored procedure from an Active Server Page. Here it is:
----------------
CREATE PROCEDURE sp_TPRandomQuestions (@testid varchar(12)) AS
SET NOCOUNT ON
CREATE TABLE #quesorder (lngQID int NOT NULL, dblRand float NULL) INSERT #quesorder (lngQID) SELECT lngQID FROM tblTPQuestions WHERE (txtTestID=@testid) ORDER BY lngNumber
DECLARE Randomizer CURSOR FOR SELECT dblRand FROM #quesorder
OPEN Randomizer FETCH NEXT FROM Randomizer
WHILE @@Fetch_Status != -1 BEGIN UPDATE #quesorder SET dblRand = rand() WHERE CURRENT OF Randomizer FETCH NEXT FROM Randomizer END
CLOSE Randomizer DEALLOCATE Randomizer
SELECT tblTPQuestions.lngQID AS QID, tblTPQuestions.txtQuestion FROM tblTPQuestions INNER JOIN #quesorder ON tblTPQuestions.lngQID = #quesorder.lngQID ORDER BY #quesorder.dblRand
RETURN
----------------
The problem is, when I run the stored procedure within my Active Server Page and then try to reference the QID field in the last SELECT statement, it bombs with the following error:
Error Type: ADODB.Recordset (0x800A0CC1) Item cannot be found in the collection corresponding to the requested name or ordinal. /tc/rand/TestEng2.asp, line 79
The error is referring to my reference of the QID field on this line: lngQID = CLng(myRs("QID"))
Now, I know that data exists in my database for this query, but I am not certain that the query above is written correctly. This query is attempting to randomize a set of questions for a test.
Please help! " |
|
|
|
|
|