ASP调用SQL Server存储过程的实际操作步骤
以下的文章主要描述的是ASP调用SQL Server存储过程的实际操作步骤,如果你对ASP调用SQL Server存储过程的实际操作步骤心存好奇的话,你就可以对以下的文章点击观看了,望大家在浏览之后会对其有更深的了解。

调用代码:
程序代码
- dim account,oldname,newname,RsCommand
- dim adCmdStoredProc,adInteger,adChar,adParamInput,adParamOutput,ReturnValue
- account = session("whoami")
- oldname = trim(Request.Form("oldname"))
- newname = trim(Request.Form("newname"))
- adCmdStoredProc = 4
- adInteger = 3
- adChar = 129
- adParamInput = 1
- adParamOutput = 2
'建立COMMAND对象
- set RsCommand = Server.CreateObject("adodb.command")
- RsCommand.CommandText = "sp_addModify13SName"
- RsCommand.ActiveConnection = conn
- RsCommand.CommandType = adCmdStoredProc
'添加参数
- RsCommand.Parameters.Append RsCommand.CreateParameter("@account", adChar, adParamInput,20,account)
- RsCommand.Parameters.Append RsCommand.CreateParameter("@oldname", adChar, adParamInput,20,oldname)
- RsCommand.Parameters.Append RsCommand.CreateParameter("@newname", adChar, adParamInput,20,newname)
- RsCommand.Parameters.Append RsCommand.CreateParameter("@ReturnValue",adInteger, adParamOutput,4)
- RsCommand.execute'执行
- ReturnValue = RsCommand.Parameters("@ReturnValue")'取出返回值
SQL Server存储过程代码:
程序代码
- Create proc sp_addstorename
- ( @account char(20),
- @oldname char(20),
- @newname char(20),
- @ReturnValue int
- )
返回1正常
返回0插入失败
返回9系统错误
- as
- Begin
- set @ReturnValue = 0
- insert into modifyname13(account,oldname,newname) values(@account,@oldname,@newname)
- if @@error > 0
- Begin
- rollback
- set @ReturnValue = 9
- End
- else
- set @ReturnValue = 1
- End
以上的相关内容就是对ASP调用SQL Server存储过程的介绍,望你能有所收获。
【编辑推荐】
- SQL Server浮点数据类型的详细解析
- 卸载SQL Server 2005组件的正确顺序
- SQL Server使用检查约束来验证数据实战演示
- SQL Server存储过程的命名标准如何进行?
- SQL Server数据库的临时表的正确操作步骤
当前文章:ASP调用SQL Server存储过程的实际操作步骤
转载来于:http://www.jxjierui.cn/article/dpsccde.html


咨询
建站咨询
