|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我想详细了解ASP整站代码与PSP整站代码有什么优缺点,那个更好,更安全,更用容易维护,和管理。。。历程ReturnValueshow-toExecuteaStoredProcs
ThisdemoItscalledReturnValue.aspandshowsyouhowtoexecuteastoredprocedurethathasinputparams,outputparams,areturnedrecordsetandareturnvalue.
<!--Author:JohnBailey-->
<%@Language=VBScript%>
<%
CODETOCREATETHESTOREDPROCEDURETHATTHISASPACCESSES
Justremoveallcommentsafterthisline,pasteintotheSQLqueryanalyzerandrun.
--insuresyouusetherightdatabase
usepubs
GO
--Createstheprocedure
createproceduresp_PubsTest
--declarethreeparametervariables
@au_lnamevarchar(20),
@intIDint,
@intIDOutintOUTPUT
AS
SELECT@intIDOut=@intID+1
SELECT*
FROMauthors
WHEREau_lnameLIKE@au_lname+%
RETURN@intID+2
%>
<%
THISISTHEASPCODE.Justrunfromtheserver.
OptionExplicit
DimCmdSP
DimadoRS
DimadCmdSPStoredProc
DimadParamReturnValue
DimadParaminput
DimadParamOutput
DimadInteger
DimiVal
DimoVal
DimadoField
DimadVarChar
adCmdSPStoredProc=4
adParamReturnValue=4
adParaminput=1
adParamOutput=2
adInteger=3
adVarChar=200
iVal=5
oVal=3
--Createacommandobject--
setCmdSP=Server.CreateObject("ADODB.Command")
--MakeanODBCconnectiontothe(local)SQLserver,
--connectingtothePubsdatabasewiththedefaultsaloginandemptypassword
CmdSP.ActiveConnection="Driver={SQLServer};server=(local);Uid=sa;Pwd=;Database=Pubs"
--definethenameofthecommand
CmdSP.CommandText="sp_PubsTest"
--definethetypeofthecommandasastoredprocedure(numericvalue=4)
CmdSP.CommandType=adCmdSPStoredProc
--definethefirstparameter-theonetheprocedurewillreturn
--thecallsare:
--CmdSP.Parameters.Append:appendthisparametertothecollectionforthiscommandobject
--CmdSP.CreateParameter():createstheparameterusingthevaluesgiven:
--"RETURN_VALUE"isthenameoftheparameterforlaterreference
--adInteger(value=3)indicatesthisparameterisanintegerdatatype
--adParamReturnValue(value=4)indicatesthisparameterisexpectedtobereturned
--4isanarbitraryinitialvalueforthisparameter
CmdSP.Parameters.AppendCmdSP.CreateParameter("RETURN_VALUE",adInteger,adParamReturnValue,4)
--definethefirstparameter-theonetheprocedurewillreturn
--thecallsare:
--CmdSP.Parameters.Append:appendthisparametertothecollectionforthiscommandobject
--CmdSP.CreateParameter():createstheparameterusingthevaluesgiven:
--"@au_lname"isthenameoftheparameterforlaterreference
--adVarChar(value=200)indicatesthisparameterisastringdatatype
--adParamInput(value=1)indicatesthisparameterisforinput
--20isthesizeofthestringincharacters
--"M"isanarbitraryinitialvalueforthisparameter
CmdSP.Parameters.AppendCmdSP.CreateParameter("@au_lname",adVarChar,adParaminput,20,"M")
--definethefirstparameter-theonetheprocedurewillreturn
--thecallsare:
--CmdSP.Parameters.Append:appendthisparametertothecollectionforthiscommandobject
--CmdSP.CreateParameter():createstheparameterusingthevalu</p>asp对于服务器的要求较高,一般的服务器如果访问量一大就垮了,不得不重启。 |
|