This article does not use the adodb.command command, but simply makes a stored procedure using adodb.recordset.
Stored procedure:
CREATE PROCEDURE [dbo].[tse]
in SQL
@keyword varchar(20)=null, 'Define the keyword of the query
@choose int=null 'Define the type of query (1 is the query column title, the others are content)
as
if @choose=1
select * from web where title like @keyword + '%'
else
select * from web where content like @keyword + '%'
return
GO
'list.asp page
<!--#include file="conn.inc" -->
<%
dimrs
dimsql
dim keyword
dim choose
keyword=request(“keyword“) 'Receive the value sent by the page
choose=request(“choose“)
set rs=server.createobject("adodb.recordset")
sql="exec tse '"&keyword&"',"&choose&"" 'Use exec to execute the tse stored procedure, and pass keyword and choose parameters to the stored procedure.
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write("No records!")
response.end
end if
response.write"The records searched are as follows:<br><br>"
do until rs.eof
response.write""&rs("id")&":"&rs("title")&"" 'Print out the ID and title of the article
response.write"<br><br>"
rs.movenext
loop
'Clean the battlefield
rs.close
conn.close
set rs=nothing
set conn = nothing
%>