仓酷云

标题: ASP教程之asp 中挪用存贮历程的一些例子.(1) [打印本页]

作者: 再现理想    时间: 2015-1-16 22:59
标题: ASP教程之asp 中挪用存贮历程的一些例子.(1)
我想详细了解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对于服务器的要求较高,一般的服务器如果访问量一大就垮了,不得不重启。
作者: admin    时间: 2015-1-20 07:15
他的语法和设计思路和VB完全相同,导致很多ASP的书都留一句“相关内容请参考VB的相关教材....”更糟糕的是,相当多的ASP教程混合了Javascript,VBscript等等脚本语言,搞的初学者。
作者: 若天明    时间: 2015-1-21 17:30
我就感觉到ASP和一些常用的数据库编程以及软件工程方面的思想是非常重要的。我现在也在尝试自己做网页,这其中就用到了ASP,我想它的作用是可想而知的。
作者: 小妖女    时间: 2015-1-30 21:34
用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。
作者: 仓酷云    时间: 2015-2-6 16:03
代码的可重用性差:由于是面向结构的编程方式,并且混合html,所以可能页面原型修改一点,整个程序都需要修改,更别提代码重用了。
作者: 再现理想    时间: 2015-2-17 00:00
ASP也是这几种脚本语言中最简单易学的开发语言。但ASP也是这几种语言中唯一的一个不能很好支持跨平台的语言。  因为ASP脚本语言非常简单,因此其代码也简单易懂,结合HTML代码,可快速地完成网站的应用程序。
作者: 变相怪杰    时间: 2015-3-5 13:34
你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。
作者: 兰色精灵    时间: 2015-3-12 07:28
它可通过内置的组件实现更强大的功能,如使用A-DO可以轻松地访问数据库。
作者: 莫相离    时间: 2015-3-19 18:40
我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标.




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2