用ASP对SQL Server存储过程进行调用流程

数据库 SQL Server
我们今天主要向大家描述的是用ASP对SQL Server存储过程进行调用的实际操作流程,以及对其实际操作代码的详细描述。

此文章主要向大家讲述的是用ASP对SQL Server存储过程进行调用的实际操作流程,我们主要是以其实际应用代码的方式来引出ASP对SQL Server存储过程进行调用的实际操作流程,以下就是文章的主要内容讲述。

调用代码:

程序代码

 

  1. dim account,oldname,newname,RsCommand  
  2. dim adCmdStoredProc,adInteger,adChar,adParamInput,adParamOutput,ReturnValue  
  3. account = session("whoami")  
  4. oldname = trim(Request.Form("oldname"))  
  5. newname = trim(Request.Form("newname"))  
  6. adCmdStoredProc = 4 
  7. adInteger = 3 
  8. adChar = 129 
  9. adParamInput = 1 
  10. adParamOutput = 2 

 

'建立COMMAND对象

 

  1. set RsCommand = Server.CreateObject("adodb.command")  
  2. RsCommand.CommandText = "sp_addModify13SName" 
  3. RsCommand.ActiveConnection = conn 
  4. RsCommand.CommandType = adCmdStoredProc 

 

'添加参数

 

  1. RsCommand.Parameters.Append RsCommand.CreateParameter("@account", adChar, adParamInput,20,account)  
  2. RsCommand.Parameters.Append RsCommand.CreateParameter("@oldname", adChar, adParamInput,20,oldname)  
  3. RsCommand.Parameters.Append RsCommand.CreateParameter("@newname", adChar, adParamInput,20,newname)  
  4. RsCommand.Parameters.Append RsCommand.CreateParameter("@ReturnValue",adInteger, adParamOutput,4)  
  5. RsCommand.execute'执行  
  6. ReturnValue = RsCommand.Parameters("@ReturnValue")'取出返回值  

 

ASP调用SQL Server存储过程代码:

程序代码

 

  1. Create proc sp_addstorename  
  2. ( @account char(20),  
  3. @oldname char(20),  
  4. @newname char(20),  
  5. @ReturnValue int  
  6. )  

 

返回1正常

返回0插入失败

返回9系统错误

 

  1. as  
  2. Begin  
  3. set @ReturnValue = 0 
  4. insert into modifyname13(account,oldname,newname) values(@account,@oldname,@newname)  
  5. if @@error > 0  
  6. Begin  
  7. rollback  
  8. set @ReturnValue = 9 
  9. End  
  10. else  
  11. set @ReturnValue = 1 
  12. End  

以上的相关内容就是对ASP调用SQL Server存储过程的介绍,望你能有所收获。
 

责任编辑:佚名 来源: 互联网
相关推荐

2010-05-19 14:13:12

MySQL存储过程

2010-07-08 17:15:04

SQL Server存

2010-11-12 09:46:55

Sql Server存

2010-07-23 14:26:37

SQL Server存

2010-06-04 13:50:24

MySQL存储过程

2010-01-22 16:48:54

VB.NET调用SQL

2012-05-10 11:17:23

JavaSQL Server

2011-06-17 17:37:16

JavaSQL Server

2010-11-10 15:16:14

Sql Server分

2011-08-22 10:15:39

数据库存储过程

2015-08-19 14:18:56

SQLasp.net后台调用

2010-07-05 17:49:15

2010-07-22 16:13:53

2011-09-01 13:43:23

VC调用SQL Ser

2011-08-29 15:52:19

SQL ServerMybatis存储过程

2009-08-06 16:44:06

2010-07-15 12:38:14

SQL Server存

2010-07-15 11:36:21

SQL Server历

2011-07-13 16:19:54

存储过程SQL Server数

2010-09-03 15:08:03

SQLselect语句
点赞
收藏

51CTO技术栈公众号