Write yourself a simple ASP call stored procedure query

Source: Internet
Author: User
Stored procedure This article used not to use the Adodb.command command, but simply did a adodb.recordset to execute the stored procedure.

Stored procedures:
' Establish Dbo.tse stored procedures in SQL

CREATE PROCEDURE [dbo]. [TSE]
@keyword varchar (=null), ' Define the keyword for the query
@choose int=null ' defines the type of query (1 is the query column title, 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"-->
<%
Dim rs
Dim sql
Dim keyword
Dim Choose
Keyword=request ("keyword") ' receives page transfer value
Choose=request ("choose")
Set Rs=server.createobject ("Adodb.recordset")
Sql= "Exec tse '" &keyword& "", "&choose&" "' Executes TSE stored procedure with exec, passes the keyword,choose to stored procedure parameters
Rs.Open sql,conn,1,1
If rs.eof and Rs.bof then
Response.Write ("no record!") ")
Response.End
End If
Response.Write "Search for records 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
' Sweep the battlefield.
Rs.close
Conn.close
Set rs=nothing
Set conn = Nothing
%>




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.