自己寫的一個簡單ASP調用預存程序查詢

來源:互聯網
上載者:User
本文用到沒有用到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
%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.