|
 |
asptoday_discuss thread: Trouble with ASP and Stored Proc RS
Message #1 by "Joe J Olsen" <joe@w...> on Fri, 12 Oct 2001 15:50:10
|
|
Hey all. I am having trouble with a stored proc and a recordset. I kkep
getting the "operation is not allowed when the object is closed" error on
the "While Not EOF" line of the following code:
Dim objCmd,objRS
Set objCmd = CreateObject("ADODB.Command")
Set objRS = CreateObject("ADODB.Recordset")
objCmd.ActiveConnection = "Driver=SQL
Server;server=20.20.20.20;Uid=userid;Pwd=pswd;Database=database"
objCmd.CommandText = "snewdemographiccountsreport"
objCmd.CommandType = adCmdStoredProc
objCmd.CommandTimeout = 60
While Not objRS.EOF
for each objField in objRS.Fields
Response.Write objField.Name & "=" & objField.Value & "<br>" &
vbCRLF
Next
Response.Write "<br>"
objRS.MoveNext
Wend
Set objRS = nothing
Set objCmd.ActiveConnection = nothing
Set objCmd = nothing
Please help if you can. I am spending way too much time trying to figure
it out myself.
Thanks.
Message #2 by "Biju.Therakathilal" <Biju.Therakathilal@t...> on Fri, 12 Oct 2001 09:56:05 -0500
|
|
Joe,
I think you did not execute the stored procedure. You will need to use
objCmd.Execute
If you pass some input parameters or get output parameters from the stored
procedure, make sure you add it to the parameters collection.
Thanks
Biju Therakathilal
-----Original Message-----
From: Joe J Olsen [mailto:joe@w...]
Sent: Friday, October 12, 2001 10:50 AM
To: ASPToday Discuss
Subject: [asptoday_discuss] Trouble with ASP and Stored Proc RS
Hey all. I am having trouble with a stored proc and a recordset. I kkep
getting the "operation is not allowed when the object is closed" error on
the "While Not EOF" line of the following code:
Dim objCmd,objRS
Set objCmd = CreateObject("ADODB.Command")
Set objRS = CreateObject("ADODB.Recordset")
objCmd.ActiveConnection = "Driver=SQL
Server;server=20.20.20.20;Uid=userid;Pwd=pswd;Database=database"
objCmd.CommandText = "snewdemographiccountsreport"
objCmd.CommandType = adCmdStoredProc
objCmd.CommandTimeout = 60
While Not objRS.EOF
for each objField in objRS.Fields
Response.Write objField.Name & "=" & objField.Value & "<br>" &
vbCRLF
Next
Response.Write "<br>"
objRS.MoveNext
Wend
Set objRS = nothing
Set objCmd.ActiveConnection = nothing
Set objCmd = nothing
Please help if you can. I am spending way too much time trying to figure
it out myself.
Thanks.
biju.therakathilal@t...
$subst('Email.Unsub')
Message #3 by "Rich McQuaid" <remcq@m...> on Fri, 12 Oct 2001 11:11:21 -0400
|
|
It looks like you didn't run the query. The command you need is:
objRS.open objCmd
Insert this befor the While loop and after you create the recordset
object.
Rich
-----Original Message-----
From: Joe J Olsen [mailto:joe@w...]
Sent: Friday, October 12, 2001 3:50 PM
To: ASPToday Discuss
Subject: [asptoday_discuss] Trouble with ASP and Stored Proc RS
Hey all. I am having trouble with a stored proc and a recordset. I kkep
getting the "operation is not allowed when the object is closed" error
on
the "While Not EOF" line of the following code:
Dim objCmd,objRS
Set objCmd = CreateObject("ADODB.Command")
Set objRS = CreateObject("ADODB.Recordset") objCmd.ActiveConnection
"Driver=SQL
Server;server=20.20.20.20;Uid=userid;Pwd=pswd;Database=database"
objCmd.CommandText = "snewdemographiccountsreport" objCmd.CommandType
adCmdStoredProc objCmd.CommandTimeout = 60
While Not objRS.EOF
for each objField in objRS.Fields
Response.Write objField.Name & "=" & objField.Value & "<br>" &
vbCRLF
Next
Response.Write "<br>"
objRS.MoveNext
Wend
Set objRS = nothing
Set objCmd.ActiveConnection = nothing
Set objCmd = nothing
Please help if you can. I am spending way too much time trying to
figure
it out myself.
Thanks.
|
|
 |