- 关 键 词:
- sql server
- 存储过程
- asp
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.execute或recordset.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静态页面:http://www.qqread.com/asp/2006/10/n223127.html
更多内容请看存储过程、网络存储—光纤通道、服务器存储专栏专题,或进入讨论组讨论。
存储过程是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.execute或recordset.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静态页面:http://www.qqread.com/asp/2006/10/n223127.html
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- asp+ajax打造无刷新新闻评论系统 (846次浏览)
- 绝对免费顶级域名+免费500MB ASP?? (728次浏览)
- ASP后门之终极伪装 (601次浏览)
- FTP的安全问题 《转》 (589次浏览)
- 如何正确显示数据库中的图片 (503次浏览)
- 用户登录/注册程序——Flash+ASP (492次浏览)
- SQL注入漏洞全接触 (381次浏览)
- asp+sqlserver 分页方法(不用存储过程) (314次浏览)
- Windows操作系统出现死机故障的解决方法 (202次浏览)
- 对ASP 动态包含文件方法的改进 (152次浏览)



