木子屋 Dnawo's BLOG

ASP中如何执行存储过程

👤 dnawo 📅 2007-01-12 👁 5197 👍 0 💬 0 🔄 本站原创
1.什么是存储过程?
存储过程是SQL server所提供的Tranact-SQL语言所编写的程序。

2. 如何建立存储过程?
Create PROCEDURE sp_query_info
@name1 varchar(20) ="张三"
AS
Select * from info where stu=@name1
GO

3. ASP中执行存储过程:

A. 编写sql语句:“execute 存储过程名 参数”,再通过connection.execute或recordset.open执行
Set objComm = Server.CreateObject("adodb.command")
objComm.CommandType = 1
objComm.ActiveConnection = objConn
objComm.CommandText = "execute sp_query_info '李四'"
Set objRs = objComm.execute
If not objRs.eof Then
Response.write objRs(1)
End if
Set objRs = Nothing
Set objComm = Nothing

B. 通command对象执行类型为acCmdStoredProc的命令
Set objComm = Server.CreateObject("adodb.command")
objComm.Parameters.append objComm.CreateParameter("@name1",200,1,50,"王五")
objComm.CommandType = 4
objComm.ActiveConnection = objConn
objComm.CommandText = "sp_query_info"
Set objRs = objComm.execute
If not objRs.eof Then
Response.write objRs(1)
End if
Set objRs = Nothing
Set objComm = Nothing

评论(0)

暂无评论。

计算题
评论需审核通过后显示
← 上一篇 这两天博客日志分析 下一篇 → ASP文件上传方式大比拼