1. What is a stored procedure?
A stored procedure is a program written in the tranact-SQL language provided by SQL Server.
2. How to Create a stored procedure?
Create procedure employeeid_orders
@ Employeeid as int
As
Select * from orders
Where employeeid = @ employeeid
3. Execute the stored procedure in ASP:
A. Write an SQL statement: "execute stored procedure name is too large, and then run it through connection.exe cute or recordset. Open.
Strsql = "execute employeeid_orders 1"
Set objrstorders = objcnnnorthwind. Execute (strsql)
B. commands whose execution type is acw.storedproc through the command object
'Create command object
Set obj1_northwind = server. Createobject ("ADODB. Command ")
'Set the command text
Obj1_northwind. commandtext = "employeeid_orders"
'Set the command type
Obj1_northwind. commandtype = ad1_storedproc
'Set the connection object used by the command object
Set obj1_northwind. activeconnection = objcnnnorthwind
'Create a parameter object
Set objparam = obj1_northwind. createparameter ("@ employeeid", adinteger, adparaminput)
'Add the parameter object to the parameter set of the command object
Obj1_northwind. Parameters. append objparam
'Set the parameter value
Objparam. value = 2
'COMMAND execution object
Set objrstorders = obj1_northwind. Execute ()
'Destroy command object
Set obj1_northwind = nothing