日期:2011-12-16 浏览次数:21068 次
/*SP1*/ CREATE PROCEDURE dbo.getUserList as set nocount on begin select * from dbo.[userinfo] end go |
'**通过Command对象调用存储过程** DIM MyComm,MyRst Set MyComm = Server.CreateObject("ADODB.Command") MyComm.ActiveConnection = MyConStr 'MyConStr是数据库连接字串 MyComm.CommandText = "getUserList" '指定存储过程名 MyComm.CommandType = 4 '表明这是一个存储过程 MyComm.Prepared = true '要求将SQL命令先行编译 Set MyRst = MyComm.Execute Set MyComm = Nothing |
'**通过Connection对象调用存储过程** DIM MyConn,MyRst Set MyConn = Server.CreateObject("ADODB.Connection") MyConn.open MyConStr 'MyConStr是数据库连接字串 Set MyRst = MyConn.Execute("getUserList",0,4) '最后一个参断含义同CommandType Set MyConn = Nothing '**通过Recordset对象调用存储过程** DIM MyRst Set MyRst = Server.CreateObject("ADODB.Recordset") MyRst.open "getUserList",MyConStr,0,1,4 'MyConStr是数据库连接字串,最后一个参断含义与CommandType相同 |
/*SP2*/ CREATE PROCEDURE dbo.delUserAll as set nocount on begin delete from dbo.[userinfo] end go |
'**通过Command对象调用存储过程** DIM MyComm Set MyComm = Server.CreateObject("ADODB.Command") MyComm.ActiveConnection = MyConStr 'MyConStr是数据库连接字串 MyComm.CommandText = "delUserAll" '指定存储过程名 MyComm.CommandType = 4 '表明这是一个存储过程 MyComm.Prepared = true '要求将SQL命令先行编译 MyComm.Execute '此处不必再取得记录集 Set MyComm = Nothing |
/*SP3*/ CREATE PROCEDURE dbo.delUserAll as set nocount on begin BEGIN TRANSACTION delete from dbo.[userinfo] IF @@error=0 begin COMMIT TRANSACTION return 1 end ELSE begin ROLLBACK TRANSACTION return 0 end return end go |
'**调用带有返回值的存储过程并取得返回值** DIM MyComm,MyPara Set MyComm = Server.CreateObject("ADODB.Command") MyComm.ActiveConnection = MyConStr 'MyConStr是数据库连接字串 MyComm.CommandText = "delUserAll" '指定存储过程名 MyComm.CommandType = 4 '表明这是一个存储过程 MyComm.Prepared = true '要求将SQL命令先行编译 '声明返回值 Set Mypara = MyComm.CreateParameter("RETURN",2,4) MyComm.Parameters.Append MyPara MyComm.Execute '取得返回值 DIM retValue retValue = MyComm(0) '或retValue = MyComm.Paramete
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
|