1. The simplest is as follows:
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 parameter, no response, no error handling.
2. A call with Parameters
Objconn. Execute "Exec sp_addhit, 'HTTP: // www.asp001.net', 1"
Note that the splitting parameter is not returned.
3.
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 '2017/123 '"
'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' you can also just specify a connection string here
. Commandtext = "sp_insertarticle"
. Commandtype = admo-storedproc '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, 99, URL)
. Parameters. append. createparameter ("@ description", adlongvarchar ,_
Adparaminput, 2147483647, description)
'Add output parameters
. Parameters. append. createparameter ("@ link_id", adinteger, adparamoutput, 0)
'Execute the Function
'If not returning A recordset, use the adexecutenorecords parameter Option
. Execute, adexecutenorecords
Link_id =. parameters ("@ link_id ")
End
5. Stored ProcedureCode
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