Use SQL statement 6 in ASP: store Query

Source: Internet
Author: User
Use SQL statement 6 in ASP: store Query
Source:
When your query is relatively simple, it does not take much time to create an SQL statement from the beginning. However, complicated queries are different. Every time you create an SQL statement from the beginning, many development errors will occur. Therefore, once the SQL statements run smoothly, you 'd better save them and call them as needed. In this way, even for a simple query, you can use the stored query statement at any time.

Assume that you have to submit a report to the team every week to point out the existing business support problems. The data needs to be selected from your database and recorded by date, at the same time, it is sorted by the categories of support questions adopted by your team. Once you have designed this query, why do you write it again every week? Do not create a query on your HTML page. You should use your database tool to create a query and save it. Then you can use the activecommand attribute to insert queries to your ASP Webpage. The first one or two times you may feel boring, but there are just a few lines of code:

Set objsq = server. Createobject ("ADODB. Command ")

Objsq. activeconnection = "databasename"

Objsq. commandtext = "storedqueryname"

Objsq. commandtype = adw.storedproc

Set objrec = objsq. Execute

Note that using adcmdstoredproc indicates that you have included the adovbs. inc file on the page. This file defines the access constant that you can access by name rather than number. You only need to include this file on the page ?! -- # Include -->), and then you can use names such as adcmdstoredproc. In this way, you will be more likely to understand the meaning of the stored query in the future.

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.