ASP calls the SQL SERVER storage Program

Source: Internet
Author: User

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)
%>

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.