最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
自己写的一个简单ASP调用存储过程查询
时间:2022-06-30 10:29:57 编辑:袖梨 来源:一聚教程网
本文用到没有用到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页
<%
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"搜索到的记录如下:
"
do until rs.eof
response.write""&rs("id")&":"&rs("title")&"" '打印出文章的ID和标题
response.write"
"
rs.movenext
loop
'打扫战场
rs.close
conn.close
set rs=nothing set conn = nothing
%>
存储过程:
'在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页
<%
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"搜索到的记录如下:
"
do until rs.eof
response.write""&rs("id")&":"&rs("title")&"" '打印出文章的ID和标题
response.write"
"
rs.movenext
loop
'打扫战场
rs.close
conn.close
set rs=nothing set conn = nothing
%>
相关文章
- 多邻国官网登录入口-Duolingo官方网页版入口 01-18
- 啥都能看的视频神器-资源最全的视频神器 01-18
- 新浪微博网页版手机端-新浪微博手机版网页入口 01-18
- 夸克网页版-夸克浏览器网页版入口 01-18
- 动漫共和国入口_动漫共和国官网与分类导航 01-18
- 绝世唐门漫画完整免费入口在哪?2026最新免费观看地址及平台汇总 01-18