最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp 中调用存贮过程的一些例子.(1)
时间:2022-06-30 10:25:44 编辑:袖梨 来源:一聚教程网
Return Values how-to Execute a Stored Proc's
This demo It's called ReturnValue.asp and shows you how to execute a stored procedure that has input params, output params, a returned recordset and a return value.
<%@ Language=VBScript %>
<%
'CODE TO CREATE THE STORED PROCEDURE THAT THIS ASP ACCESSES
'Just remove all comments after this line, paste into the SQL query analyzer and run.
'-- insures you use the right database
'use pubs
'GO
'
'-- Creates the procedure
'create procedure sp_PubsTest
'
'-- declare three parameter variables
' @au_lname varchar (20),
' @intID int,
' @intIDOut int OUTPUT
'
'AS
'
'SELECT @intIDOut = @intID + 1
'
'SELECT *
'FROM authors
'WHERE au_lname LIKE @au_lname + '%'
'RETURN @intID + 2
%>
<%
'THIS IS THE ASP CODE. Just run from the server.
Option Explicit
Dim CmdSP
Dim adoRS
Dim adCmdSPStoredProc
Dim adParamReturnValue
Dim adParaminput
Dim adParamOutput
Dim adInteger
Dim iVal
Dim oVal
Dim adoField
Dim adVarChar
adCmdSPStoredProc = 4
adParamReturnValue = 4
adParaminput = 1
adParamOutput = 2
adInteger = 3
adVarChar = 200
iVal = 5
oVal = 3
'-- Create a command object --
set CmdSP = Server.CreateObject("ADODB.Command")
'-- Make an ODBC connection to the (local) SQL server,
'-- connecting to the Pubs database with the default sa login and empty password
CmdSP.ActiveConnection = "Driver={SQL Server};server=(local);Uid=sa;Pwd=;Database=Pubs"
'-- define the name of the command
This demo It's called ReturnValue.asp and shows you how to execute a stored procedure that has input params, output params, a returned recordset and a return value.
<%@ Language=VBScript %>
<%
'CODE TO CREATE THE STORED PROCEDURE THAT THIS ASP ACCESSES
'Just remove all comments after this line, paste into the SQL query analyzer and run.
'-- insures you use the right database
'use pubs
'GO
'
'-- Creates the procedure
'create procedure sp_PubsTest
'
'-- declare three parameter variables
' @au_lname varchar (20),
' @intID int,
' @intIDOut int OUTPUT
'
'AS
'
'SELECT @intIDOut = @intID + 1
'
'SELECT *
'FROM authors
'WHERE au_lname LIKE @au_lname + '%'
'RETURN @intID + 2
%>
<%
'THIS IS THE ASP CODE. Just run from the server.
Option Explicit
Dim CmdSP
Dim adoRS
Dim adCmdSPStoredProc
Dim adParamReturnValue
Dim adParaminput
Dim adParamOutput
Dim adInteger
Dim iVal
Dim oVal
Dim adoField
Dim adVarChar
adCmdSPStoredProc = 4
adParamReturnValue = 4
adParaminput = 1
adParamOutput = 2
adInteger = 3
adVarChar = 200
iVal = 5
oVal = 3
'-- Create a command object --
set CmdSP = Server.CreateObject("ADODB.Command")
'-- Make an ODBC connection to the (local) SQL server,
'-- connecting to the Pubs database with the default sa login and empty password
CmdSP.ActiveConnection = "Driver={SQL Server};server=(local);Uid=sa;Pwd=;Database=Pubs"
'-- define the name of the command
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22