|
技术资料 > ASP技术 > 数据库相关 : 一段测试不用COMMAND对象来调用存储过程的ASP代码 |
一段测试不用COMMAND对象来调用存储过程的ASP代码 March 25,2004 |
他说如果返回多个值,比如纪录集以及返回值一定要用COMMAND对象。。我现在终于搞定了。。:)
<%@ Language=VBScript %>
<%
'一段测试不用COMMAND对象来调用存储过程的ASP代码 作者:大自然 信箱:[email protected] 主页:http://zhanzhen.wayall.com
'----------------------------------------------------------------------------------------------------
'CREATE PROCEDURE TopNewsSP
' @intTopRow Int,
' @vcInputMsg Varchar(20),
' @vcReturnMsg Varchar(20) OUTPUT
'AS
' SET ROWCOUNT @intTopRow
' SELECT id,标题,发布日期,关键字 FROM news WHERE 关键字 ='公告通知' ORDER BY 发布日期 DESC,Id DESC
' SELECT id,标题,发布日期,关键字 FROM news WHERE 关键字 ='娱乐新闻' ORDER BY 发布日期 DESC,Id DESC
' IF @vcInputMsg = '男'
' SELECT @vcReturnMsg = '男人'
' ELSE
' SELECT @vcReturnMsg = '女人'
'----------------------------------------------------------------------------------------------------
Option Explicit
Dim Conn, Rs, RsCount, SqlQuery
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "itrd", "sa"
SqlQuery = "DECLARE @returnmsg varchar(20)" & VbCrLf & "EXEC TopNewsSP 5, '男', @returnmsg OUTPUT" & VbCrLf & "SELECT @returnmsg"
Set Rs = Conn.Execute(SqlQuery)
RsCount = 1
Do Until Rs Is Nothing
Rs.MoveFirst
While Not Rs.Eof
Response.Write Rs(0)
Rs.MoveNext
Wend
Response.Write "第" & RsCount & "个RS对象<br>"
RsCount = RsCount + 1
Set Rs = Rs.NextRecordSet
Loop
Set Rs = Nothing
Conn.Close
Set Conn = Nothing
%>
|
|
Copyright © 2001-2008 Shenzhen Hiblue Software Team All rights reserved