A simple ASP call Stored Procedure Query

Source: Internet
Author: User

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

%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.