|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP最大的缺点在于网络的安全性和可靠性,企业将经营数据放在开放的平台上,最大的担忧就是如何保证这些数据不被其他人破坏。存储历程1、挪用没有参数的存储历程
<%
setconn=server.CreateObject("adodb.connection")
setcmd=server.CreateObject("adodb.command")
strconn="dsn=pubs;uid=sa;pwd"
conn.Openstrconn
setcmd.ActiveConnection=conn
cmd.CommandText="{callnono}"
setrs=cmc.exe大概cmd.execute
setrs=cmd.Execute()
%>
2、一个输出的参数的存储历程
<%
setconn=server.CreateObject("adodb.connection")
setcmd=server.CreateObject("adodb.command")
strconn="dsn=pubs;uid=sa;pwd"
conn.Openstrconn
setcmd.ActiveConnection=conn
cmd.CommandText="{calloneinput(?)}"
cmd.Parameters.Appendcmd.CreateParameter("@aaa",adInteger,adParamInput)
cmd("@aaa")=100
cmd.Execute()
%>
3、一个输出参数和一个输入的参数
<%
setconn=server.CreateObject("adodb.connection")
setcmd=server.CreateObject("adodb.command")
strconn="dsn=pubs;uid=sa;pwd"
conn.Openstrconn
setcmd.ActiveConnection=conn
cmd.CommandText="{calloneinout(?,?)}"
cmd.Parameters.Appendcmd.CreateParameter("@aaa",adInteger,adParamInput)
cmd("@aaa")=10
cmd.Parameters.Appendcmd.CreateParameter("@bbb",adInteger,adParamOutput)
cmd.Execute()
bbb=cmd("@bbb")
%>
4、一个输出参数,一个输入参数,和一个前往值
<%
setconn=server.CreateObject("adodb.connection")
setcmd=server.CreateObject("adodb.command")
strconn="dsn=pubs;uid=sa;pwd"
conn.Openstrconn
setcmd.ActiveConnection=conn
cmd.CommandText="{?=callonereturn(?,?)}"
cmd.Parameters.Appendcmd.CreateParameter("@return_value",adInteger,adParamReturnValue)
cmd.Parameters.Appendcmd.CreateParameter("@aaa",adInteger,adParamInput)
cmd("@aaa")=10
cmd.Parameters.Appendcmd.CreateParameter("@bbb",adInteger,adParamOutput)
cmd.Execute()
bbb=cmd("@bbb")
rrr=cmd("@return_value")
%>
怎样在ASP中挪用SQL存储历程
<%setconnection1=Server.CreateObject("ADODB.Connection")
connection1.open...连接
setcommand1=Server.CreateObject("ADODB.command")
setcommand1.activeconnection=connection1
command1.commandtype=4
command1.commandtext="sp_1"SP名
command1.parameters(1)=...参数值
command1.parameters(2)=...
setrecordset1=command1.execute()
%>
ASP挪用存储历程的技能
1、最复杂的以下
DimobjConn
SetobjConn=Server.CreateObject("ADOBD.Connection")
objConn.OpenApplication("Connection_String")
Callthestoredproceduretoincrementacounteronthepage
objConn.Execute"execsp_AddHit"
没有参数,没有前往,没有毛病处置,就是这个了
2、带参数的一种挪用
objConn.Execute"execsp_AddHithttp://www.aspalliance.com,1"
请注重支解参数,该办法也不前往纪录
3、前往纪录的
DimobjConn
DimobjRs
SetobjConn=Server.CreateObject("ADOBD.Connection")
SetobjRs=Server.CreateObject("ADOBD.Recordset")
objConn.OpenApplication("Connection_String")
Callthestoredproceduretoincrementacounteronthepage
objRs.OpenobjConn,"execsp_ListArticles1/15/2001"
Loopthroughrecordsetanddisplayeacharticle
4、……
DimobjConn
DimobjCmd
Instantiateobjects
SetobjConn=Server.CreateObject("ADODB.Connection")
setobjCmd=Server.CreateObject("ADODB.Command")
conn.OpenApplication("ConnectionString")
WithobjCmd
.ActiveConnection=connYoucanalsojustspecifyaconnectionstringhere
.CommandText="sp_InsertArticle"
.CommandType=adCmdStoredProcRequirestheadoVBs.incfileortypelibmetatag
AddInputParameters
.Parameters.Append.CreateParameter("@columnist_id",adDouble,adParamInput,,columnist_id)
.Parameters.Append.CreateParameter("@url",adVarChar,adParamInput,255,url)
.Parameters.Append.CreateParameter("@title",adVarChar,adParamInput,99,url)
.Parameters.Append.CreateParameter("@description",adLongVarChar,_
adParamInput,2147483647,description)
AddOutputParameters
.Parameters.Append.CreateParameter("@link_id",adInteger,adParamOutput,,0)
Executethefunction
Ifnotreturningarecordset,usetheadExecuteNoRecordsparameteroption
.Execute,,adExecuteNoRecords
link_id=.Parameters("@link_id")
EndWith
5、存储历程的代码
CreatePROCEDUREdbo.sp_InsertArticle
(
@columnist_idint,
@urlvarchar(255),
@titlevarchar(99),
@descriptiontext
@link_idintOUTPUT
)
AS
BEGIN
INSERTINTOdbo.t_link(columnist_id,url,title,description)
VALUES(@columnist_id,@url,@title,@description)
SELECT@link_id=@@IDENTITY
END
asp对于服务器的要求较高,一般的服务器如果访问量一大就垮了,不得不重启。 |
|