ASP

本类阅读TOP10

·asp常用数据库连接方法和技巧
·无组件生成BMP验证码
·一些常用的辅助代码 (网络收藏)
·JavaScript实现的数据表格:冻结列、调整列宽和客户端排序
·VisualStudio.NET_2003及其 MSDN 下载地址
·ASP模拟MVC模式编程
·图片以二进制流输出到网页
·MD5加密算法 ASP版
·ASP.NET编程中的十大技巧
·改进 ASP 的字符串处理性能

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
ASP中如何执行存储过程?

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

1.      什么是存储过程?

存储过程是SQL server所提供的Tranact-SQL语言所编写的程序。

2.      如何建立存储过程?

Create Procedure EmployeeID_Orders

@EmployeeID as int

as

select * from orders

where employeeID=@EmployeeID

3.      ASP中执行存储过程:

A.         编写sql语句:“execute 存储过程名 参数”,再通过connection.executerecordset.open执行

strSql="execute employeeID_Orders 1"

Set objRstOrders=objCnnNorthwind.Execute(strSql)

B.         command对象执行类型为acCmdStoredProc的命令

建立Command对象

Set objCmdNorthwind=Server.CreateObject("ADODB.Command")

设定命令的文本

objCmdNorthwind.CommandText="EmployeeID_Orders"

设定命令的类型

objCmdNorthwind.CommandType=adCmdStoredProc

设定命令对象使用的连接对象

Set objCmdNorthwind.ActiveConnection=objCnnNorthwind

 

建立参数对象

Set objParam=objCmdNorthwind.CreateParameter("@EmployeeID",adInteger,adParamInput)

把参数对象添加到命令对象的参数集中

objCmdNorthwind.Parameters.Append objParam

设定参数的值

objParam.Value=2

 

执行命令对象

Set objRstOrders=objCmdNorthwind.Execute()

销毁命令对象

Set objCmdNorthwind=Nothing




相关文章

相关软件