ASP calls the SQL SERVER storage Program
Source http://www.bmj2000.com/vb/techniccolumn/subDetail.asp? MainId = 2 & BoardId = asp & ItemId = % CA % FD % BE % DD % BF % E2 % B2 % D9 % D7 % F7 & RecId = 2216
Call database Stored Procedures
<%
Set Dataconn = Server. CreateObject ("ADODB. Connection ")
'Establish a connection object
Dataconn. Open "DSN = SinoTrans; SERVER = APP_SERVER; UID = sa; PWD =; APP = Microsoft (R) Developer Studio; WSID = APP_SERVER; Regional = Yes"
Set parameters temp = Server. CreateObject ("ADODB. Command ")
'Create command object
Set rst = Server. CreateObject ("ADODB. Recordset ")
'Create record set object
Export temp. CommandText = "dbo. pd_test" 'stored procedure name
Optional temp. CommandType = 4
'COMMAND category is 4, which indicates a stored procedure
Set consumer temp. ActiveConnection = Dataconn
Set tmpParam = gradient temp. CreateParameter ("Return Value", 3, 4, 4)
Using temp. Parameters. Append tmpParam
Set tmpParam = gradient temp. CreateParameter ("@ BeginDate", 135, 1, 16, riqi)
'Create input parameter object
Using temp. Parameters. Append tmpParam
Rst. Open keys temp, 1, 3
'Query result generation
%>
The stored procedure called here is pd_test, which is the standard method provided in ADO, but there is a problem that when there are more than two SELECT statements in the stored procedure, but logically, it is impossible for ADO to EXECUTE multiple SELECT statements in the stored procedure. The solution is to directly EXECUTE the stored procedure using the EXECUTE method of the CONNECTION object of ADO, as follows:
<%
Set Dataconn = Server. CreateObject ("ADODB. Connection ")
'Establish a connection object
Dataconn. Open "DSN = SinoTrans; SERVER = APP_SERVER; UID = sa; PWD =; APP = Microsoft (R) Developer Studio; WSID = APP_SERVER; Regional = Yes"
Ss = "EXECUTE dbo. pd_test" & "'" & riqi1 &"'"
Set rs = dataconn. Execute (ss)
%>