Techniques for ASP invoking stored procedures _ Application techniques
Source: Internet
Author: User
1, the simplest of the following
Dim objconn
Set objconn = Server.CreateObject ("ADOBD. Connection ")
objConn.Open application ("connection_string")
' Call the stored procedure to increment a counter on the page
objConn.Execute "Exec sp_addhit"
No arguments, no return, no error handling, that's it.
2, with a parameter of a call
objConn.Execute "exec sp_addhit, ' http://www.asp001.net ', 1"
Note the split parameter and the method does not return records
3, returns the record
Dim objconn
Dim objRS
Set objconn = Server.CreateObject ("ADOBD. Connection ")
Set objRS = Server.CreateObject ("ADOBD. Recordset ")
objConn.Open application ("connection_string")
' Call the stored procedure to increment a counter on the page
Objrs.open objconn, "exec sp_listarticles ' 1/15/2001"
' Loop through recordset and display each article
4 、......
Dim objconn
Dim objcmd
' Instantiate objects
Set objconn = Server.CreateObject ("ADODB. Connection ")
Set objcmd = Server.CreateObject ("Adodb.command")
Conn. Open application ("ConnectionString")
With objCMD
. ActiveConnection = Conn ' can also just specify a connection string here
. CommandText = "Sp_insertarticle"
. CommandType = adCmdStoredProc ' Requires the Adovbs.inc file or typelib meta tag
' Execute ' function
' If not returning a recordset, use the adexecutenorecords parameter option
. Execute, adExecuteNoRecords.
link_id =. Parameters ("@link_id")
End With
5, the code of the stored procedure
Create PROCEDURE dbo.sp_insertarticle
(
@columnist_id int,
@url varchar (255),
@title varchar (99),
@description text
@link_id int OUTPUT
)
As
BEGIN
INSERT into Dbo.t_link (columnist_id,url,title,description)
VALUES (@columnist_id, @url, @title, @description)
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