当前位置: 首页 > 图文教程 > 网络编程 > ASP > 自己写的一个简单ASP调用存储过程查询

ASP
Server Application Error错误解决思路
ASP教程:在IIS环境下自己设置404页面
ASP代码出现80040e14错误的解决方法
Http_Referer,Server_Name和Http_Host
HTTP_X_FORWARDED_FOR和REMOTE_ADDR
总结的Server.Mappath的用法
巧用ASP脚本命令重启服务器
实现数字字符串的最大值、最小值和平均值
详解ASP脚本的执行顺序
理解认识阿里妈妈淘客系统对外接口通用规范
网站开发者参考:开源ASP网站源码
IIS管理程序Adsutil.vbs修改FTP服务器的PASV端口范围
ASP程序中调用函数Now()异常的问题
流量大的网站不要选择万能空间
网站挂马方式大总结
启动 W3SVC 服务报错怎么解决
Vista系统安装IIS7配置ASP运行环境
Server Application Error 8004EOOF错误
ASP不用模板直接简单生成HTML页面
ASP教程:gb2312和utf-8乱码问题解决

自己写的一个简单ASP调用存储过程查询


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 133 ::
收藏到网摘: n/a

 

本文用到没有用到adodb.command命令,只是简单的做了一个用adodb.recordset来执行存储过程。

存储过程:
'在SQL中建立dbo.tse存储过程

CREATE PROCEDURE [dbo].[tse]
@keyword varchar(20)=null,  '定义查询的关键字
@choose int=null                    '定义查询的类型(1为查询列title,其他为content)
as
if @choose=1
select * from web where title like @keyword + '%'
else
select * from web where content like @keyword + '%'
return
GO

 

'list.asp页
<!--#include file="conn.inc" -->
<%
dim rs
dim sql
dim keyword
dim choose
keyword=request(“keyword“) '接收页面传送的值
choose=request(“choose“)
set rs=server.createobject("adodb.recordset")
sql="exec tse '"&keyword&"',"&choose&""     '用exec执行tse存储过程,把keyword,choose给存储过程传递参数
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write("没有任何记录!")
response.end
end if
response.write"搜索到的记录如下:<br><br>"
do until rs.eof 
response.write""&rs("id")&":"&rs("title")&""   '打印出文章的ID和标题
response.write"<br><br>"
rs.movenext
loop
'打扫战场
rs.close
conn.close
set rs=nothing           
set conn = nothing   
%>