How to use ASP stored procedures

Source: Internet
Author: User
1. Use the Command object and Parameter object to pass parameters
This document describes how to use the Microsoft SQL Server7.0 database to create a connection file AdoSQL7.asp for backup.
<% 'Adosql7. asp
Option Explicit
Response. Expires = 0

'Part 1: establish a connection
Dim Cnn, StrCnn
Set Cnn = Server. CreateObject ("ADODB. Connection ")
StrCnn = "Provider = sqloledb; User ID = sa; Password =; Initial Catalog = pubs; Data Source = ICBCZJP"
Cnn. Open StrCnn
%>
Note: Set Data Source to the name of the machine where your database server is located.
In addition, in the past, Microsoft Access97 was used to conveniently view fields and data, while SQL Server databases were not used on database servers, when debugging ASP scripts on another machine, you need to install another tool to view the fields and data. Here we provide you with a tool: Msqry32.exe (Microsoft Query ), this file is installed with Office97 and is generally located under the Microsoft Office Directory.
For example, wuf70.asp:
<% @ LANGUAGE = "VBSCRIPT" %>
<! -- # Include file = "AdoSQL7.asp" -->
<! -- # Include file = "adovbs. inc" -->
<% 'Wuf70.asp
Dim release test, prmTest, rsTest
'Create Command object
Set Release test = Server. CreateObject ("ADODB. Command ")
'Recordset and Command objects can all be connected to the Connection object through the ActiveConnection attribute.
Using test. ActiveConnection = Cnn
'SQL command-contains two parameters. Use? Indicates
Export test. CommandText = "Update jobs Set job_desc =? Where job_id =? "
'Set command type to SQL statement
Export test. CommandType = ad1_text
The 'prepared attribute determines whether to compile the SQL command first and set it to True to accelerate the running.
Required test. Prepared = True

'Create a Parameter object
Set prmTest = Route test. CreateParameter ("job_desc", adVarChar, adParamInput, 50, "Network ")
'Append the data to the Parameters dataset.
Using test. Parameters. Append prmTest

Set prmTest = Route test. CreateParameter ("job_id", adSmallInt, adParamInput, "12 ")
Using test. Parameters. Append prmTest

'Modify? You do not need to return results. Simply use export test. Execute.
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.