I have an ASP page calling a stored procedure with returned values AND OUTPUT parameters.
我有一个ASP页面调用存储过程与返回值AND OUTPUT参数。
The output parameters aren't displaying and I'm not understanding why:
输出参数没有显示,我不明白为什么:
<%
dim Objrs, cmd
set Objrs = Server.CreateObject("ADODB.RecordSet")
set cmd = Server.CreateObject("ADODB.Command")
set conn = Server.CreateObject("ADODB.Connection")
conn.Open strConnect
set cmd.ActiveConnection = conn
cmd.CommandText="MKTG_Current"
cmd.CommandType=adCmdStoredProc
cmd.Parameters.Append cmd.CreateParameter("@added", 135, 2)
cmd.Parameters.Append cmd.CreateParameter("@named", 200, 2, 50)
set Objrs = cmd.Execute
%>
</div>
<div id="recent-news-box" class="rounded-corners-top dropshadow">
<h3 class="border-dashed-b">Updated on: <%=Objrs.state%></h3>
<div>
<%
While Not Objrs.EOF
Response.Write Objrs("Subject")
Objrs.MoveNext
Wend
name_of_table = cmd.Parameters("@named").value
added = cmd.Parameters("@added").value
set cmd = nothing
set Objrs = nothing
conn.close
set conn = nothing
Response.Write name_of_table
Response.Write added
%>
</div>
</div>
</div>
I've tried changing the position of the output items to no avail.
我试过改变输出项的位置无济于事。
1 个解决方案
#1
0
There is some clunkiness because of the way ADO returns command results to both a recordset and as output paramaters.
由于ADO将命令结果返回到记录集和输出参数的方式,因此存在一些笨拙。
They are available after the returned recordset is closed, so this order should work:
返回的记录集关闭后,它们可用,因此该顺序应该有效:
set Objrs = nothing
name_of_table = cmd.Parameters("@named").value
added = cmd.Parameters("@added").value
set cmd = nothing
conn.close
set conn = nothing
Response.Write name_of_table
Response.Write added
An alternative is to leave the code as it is add switch to a client side cursor with:
另一种方法是保留代码,因为它是添加开关到客户端游标,具有:
conn.Open strConnect
conn.CursorLocation = 3 '//aduseclient
set cmd.ActiveConnection = conn
(Also check that your use of adCmdStoredProc
should not be replaced with its numeric value if your not linked to a typelib)
(如果未链接到类型库,请检查您的adCmdStoredProc的使用是否不应替换为其数值)
#1
0
There is some clunkiness because of the way ADO returns command results to both a recordset and as output paramaters.
由于ADO将命令结果返回到记录集和输出参数的方式,因此存在一些笨拙。
They are available after the returned recordset is closed, so this order should work:
返回的记录集关闭后,它们可用,因此该顺序应该有效:
set Objrs = nothing
name_of_table = cmd.Parameters("@named").value
added = cmd.Parameters("@added").value
set cmd = nothing
conn.close
set conn = nothing
Response.Write name_of_table
Response.Write added
An alternative is to leave the code as it is add switch to a client side cursor with:
另一种方法是保留代码,因为它是添加开关到客户端游标,具有:
conn.Open strConnect
conn.CursorLocation = 3 '//aduseclient
set cmd.ActiveConnection = conn
(Also check that your use of adCmdStoredProc
should not be replaced with its numeric value if your not linked to a typelib)
(如果未链接到类型库,请检查您的adCmdStoredProc的使用是否不应替换为其数值)