Using stored procedures in ASP

Source: Internet
Author: User
To improve the efficiency of ASP programs, it is sometimes necessary to use SQL Server storage technology in ASP, which is briefly described below. Establishment of stored procedures
Here is a brief description of how to establish a stored procedure in SQL Server Enterprise Manager: (1) Open Enterprise Manager Enterprise Manager
(2) Select server groups (SQL Server group), servers, databases (database), and the database, the mouse
Right-click the Stored procdures item in the corresponding database, select New Stored Procedure in the pop-up menu, Stored
In Procedures properties, enter the statement that establishes the stored procedure. Here is an example:
CREATE PROCEDURE proctest @mycola char (@mycolb char), @mycolc text as
Insert into Chatdata (MYCOLA,MYCOLB,MYCOLC) VALUES (@mycola, @mycolb, @mycolc)
In SQL Server's document, its syntax is: CREATE proc[edure] procedure_name [; number] [
{@parameter Data_type} [Varying] [= default] [OUTPUT]]
[,... N] [With {RECOMPILE | Encryption
| RECOMPILE, encryption}] [for REPLICATION] as
Sql_statement [... n] If you are unfamiliar with SQL syntax, you can use the check syntax to check the syntax.
In the example above, a stored procedure named Mycola with 3 parameters was established, where the first parameter Mycola
The data type is char, width 10; the 2nd parameter data type is char, the width is 10, and the 3rd parameter data type is text, where the data type of SQL Server is used.
After the stored procedure is established, the following is how to invoke the stored procedure in an ASP program: Invoking the stored procedure in ASP <%
Set con = Server.CreateObject ("ADODB.") Connection ")
Con.open "Driver=sql Server; Server=webdata; Database=mydatabasename; Uid=sa; Pwd= "
Set cm = Server.CreateObject ("Adodb.command") set cm. ActiveConnection = con
Cm.commandtext = "Proctest" corresponds to stored procedure name established in SQL Server
Cm.commandtype = 4 ' commandtype represents the stored procedure set p = cm. Parameters
P.append cm. CreateParameter ("@mycola", 202,1,10) ' Add 3 parameters to command
P.append cm. CreateParameter ("@mycolb", 130,1,10)
P.append cm. CreateParameter ("@mycolc", 201,1,250) cm ("@mycola") = "2000-06-31"
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.