Using SQL statements in ASP 6: Storing queries

Source: Internet
Author: User
Tags html page include
statement when your query is relatively simple, every time you create a SQL statement from scratch is not time-consuming, however, complex queries are different, each time from scratch will produce a lot of development errors. So, once you have SQL running smoothly, you'd better save them and call them when you need them. In this way, even a simple query you can always use the stored query statement.

Let's say you have a weekly report to the team, pointing out the current business support issues that need to be selected from your database, and to select records by date, and sort by the category of support issues that your team uses. Once you have designed this query, why should you rewrite it every week? Instead of creating a query on your HTML page, you should create a query with your database tools and save it. You can then insert the query into your ASP page using the ActiveCommand attribute. The first one or two of the time you might think it's no fun, but it's just a few lines of code:
Set objsq = Server.CreateObject ("Adodb.command")
Objsq.activeconnection = "DatabaseName"

Objsq.commandtext = "Storedqueryname"
Objsq.commandtype = adCmdStoredProc

Set Objrec = Objsq.execute

Note that using adCmdStoredProc means that you have included Adovbs.inc files on the page. This file defines the access constants that you can access by name rather than by number. Just need to include the file on the page?! --#INCLUDE-->), and then you can use adCmdStoredProc names like this. This will make it easier to understand what the above stored query means in the future when you see it.



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.