| 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. |