In this article, the ADODB. Command command is not used, but the stored procedure is simply executed using ADODB. recordset.
Stored Procedure:
'Create a DBO. Tse stored procedure in SQL
Create procedure [DBO]. [Tse]
@ Keyword varchar (20) = NULL, 'define the query keyword
@ Choose Int = null' defines the query type (1 is the query column title, and the other is the 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" -->
<%
Dim rs
Dim SQL
Dim keyword
Dim choose
Keyword = request ("keyword") 'receives the value sent from 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 the keyword and choose parameters to the stored procedure.
Rs. Open SQL, Conn, 1, 1
If Rs. EOF and Rs. bof then
Response. Write ("no record! ")
Response. End
End if
Response. Write "The searched records are as follows: <br>"
Do until Rs. EOF
Response. Write "" & RS ("ID") & ":" & RS ("title") & "'print Article ID and title
Response. Write "<br>"
Rs. movenext
Loop
'Clean the battlefield
Rs. Close
Conn. Close
Set rs = nothing
Set conn = nothing
%>