Stored Procedure | Tip 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.aspalliance.com ', 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
' Add Input Parameters
. Parameters.Append. CreateParameter ("@columnist_id", addouble, adParamInput, columnist_id)
. Parameters.Append. CreateParameter ("@url", adVarChar, adParamInput, 255, URL)
. Parameters.Append. CreateParameter ("@title", adVarChar, adParamInput, the URL)
. Parameters.Append. CreateParameter ("@description", adLongVarChar, _
adParamInput, 2147483647, description)
' Add Output Parameters
. Parameters.Append. CreateParameter ("@link_id", Adinteger, adParamOutput, 0)
' 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)
SELECT @link_id = @ @IDENTITY
End