Tuesday, March 27, 2012

Calling SQL Stored Procedure from ASP

Hi friends, i want to call a SP from ASP (not dot net) that returns some man
y
rows.
The conn string is:
<%
Set objCon = CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
objcon.connectionstring = "Provider=SQLOLEDB.1;User
ID=USER;Password=XXXX;Persist Security Info=True;Initial Catalog=opessa;Data
Source=SERVER01"
iCursorType = 1
iLockType = 3
objCon.Open
%>
Then i use the following sentence to call the SP from ASP
SQLtxt = "exec SPNAME '" & PARAM1 & "','" & PARAM2 & "','" & PARAM3 & "'"
objRS.open SQLTXT, objcon
And last, i try to print the results:
WHILE NOT ObjRS.EOF
Response.Write "" & ObjRS("XXXXX").VALUE & "" &
ObjRS("XXXXX").VALUE & "" & ObjRS("XXXXX").VALUE & " Mb" & "" &
ObjRS("XXXXX").VALUE & " Mb" & "" & ObjRS("XXXXX").VALUE & " %" & ""
ObjRS.Movenext
WEND
ObjRS.CLOSE
But i receive the following error:
ADODB.Recordset error '800a0e78'
Operation is not allowed when the object is closed.
Whats wrong? Anyone can help me?
Thanks in advance.Tincho wrote:
> Hi friends, i want to call a SP from ASP (not dot net) that returns
> some many rows.
Here is my canned reply on this topic:
http://groups.google.com/groups?hl=...FTNGP12.phx.gbl
Bob barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||I found the solution:
I forgot the command:
set nocount inside the stored_procedure.
Best regards!
"Bob Barrows [MVP]" wrote:

> Tincho wrote:
> Here is my canned reply on this topic:
> http://groups.google.com/groups?hl=...FTNGP12.phx.gbl
> Bob barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>|||Make sure the stored procedure has SET NOCOUNT ON.
"Tincho" <Tincho@.discussions.microsoft.com> wrote in message
news:D15145D5-A0CF-4BA3-B211-6532936B1E92@.microsoft.com...
> Hi friends, i want to call a SP from ASP (not dot net) that returns some
> many
> rows.
> The conn string is:
> <%
> Set objCon = CreateObject("ADODB.Connection")
> Set objRS = CreateObject("ADODB.Recordset")
> objcon.connectionstring = "Provider=SQLOLEDB.1;User
> ID=USER;Password=XXXX;Persist Security Info=True;Initial
> Catalog=opessa;Data
> Source=SERVER01"
> iCursorType = 1
> iLockType = 3
> objCon.Open
> %>
> Then i use the following sentence to call the SP from ASP
> SQLtxt = "exec SPNAME '" & PARAM1 & "','" & PARAM2 & "','" & PARAM3 & "'"
> objRS.open SQLTXT, objcon
> And last, i try to print the results:
> WHILE NOT ObjRS.EOF
> Response.Write "" & ObjRS("XXXXX").VALUE & "" &
> ObjRS("XXXXX").VALUE & "" & ObjRS("XXXXX").VALUE & " Mb" & "" &
> ObjRS("XXXXX").VALUE & " Mb" & "" & ObjRS("XXXXX").VALUE & " %" & ""
> ObjRS.Movenext
> WEND
> ObjRS.CLOSE
> But i receive the following error:
> ADODB.Recordset error '800a0e78'
> Operation is not allowed when the object is closed.
> Whats wrong? Anyone can help me?
> Thanks in advance.
>
>

No comments:

Post a Comment