ASP invokes SQL Server stored program

Source: Internet
Author: User
Tags dsn
Calling a database stored procedure
<%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 cmdtemp = Server.CreateObject ("Adodb.command")
' Create a Command object
Set rst = Server.CreateObject ("ADODB.") Recordset ")
' Set up a Recordset object
Cmdtemp.commandtext = "dbo.pd_test" Stored procedure name
Cmdtemp.commandtype = 4
' Command category is 4, represented as stored procedure
Set cmdtemp.activeconnection = DataConn
Set Tmpparam = Cmdtemp.createparameter ("Return Value", 3, 4, 4)
CmdTemp.Parameters.Append Tmpparam
Set Tmpparam = Cmdtemp.createparameter ("@BeginDate", 135, 1, Riqi)
' Create an input parameter object
CmdTemp.Parameters.Append Tmpparam
Rst. Open cmdtemp, 1, 3
' Generate query Results
%>
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 it is logically impossible to execute concurrently, ADO prompts you that there are too many SELECT statements in the stored procedure. The workaround is to execute the stored procedure directly using the Execute method of the ADO Connection object, 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.