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

ASP
在ASP文件中调用DLL
ASP服务器组件的编程
在ASP.NET访问Excel文件
ADO.NET:通向未来之桥
ASP.Net的几大热点问题
DataList控件也玩分页
ASP.NET高级应用(1)
ASP.NET高级应用(2)
ASP.NET高级应用(3)
关于ASP.Net中的时间处理
ASP编写完整的一个IP所在地搜索类
ASP发送E-MAIL
建立MSXML 测试环境
怎样创建.NET Web Service
怎样创建.NET Web Service(2)
怎样创建.NET Web Service(3)
怎样创建.NET Web Service(4)
ASP.NET中的HTMLControl和WebControl
比尔·盖茨在微软开发者成功之路大会上的主题演讲
运用.NET读写Windows注册编辑表

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 65 ::
收藏到网摘: 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   
%>