Asp scheduled operations Asp timed database reading (detailed webpage scheduled operations)

Source: Internet
Author: User

Currently, scheduled operations include:
1. Regular Refresh of Html pages (Refresh-Refresh)
1. Refresh (Refresh) code instructions
Note: The time (in seconds) for a webpage to refresh itself, or the time after which the webpage is automatically linked to another webpage.
Usage: <Meta http-equiv = "Refresh" Content = "30">
<Meta http-equiv = "Refresh" Content = "5; Url = http://www.jb51.net">
Note: 5 indicates that the URL is automatically refreshed after 5 seconds.
2. How to perform scheduled operations
You can refresh the page to perform scheduled operations.
Example: <meta http-equiv = "refresh" content = "5; URL = http://www.jb51.net">
Disadvantage: to open the page in a browser, you cannot close it.
Ii. setTimeout and setInterval in Javascript
1. Difference Between setTimeout and setInterval
Window objects have two main timing Methods: setTimeout and setInteval. Their syntaxes are basically the same, but their functions are different.
The setTimeout method is a Timer Program, that is, after what time. After the job is finished, pull it down.
The setInterval method indicates that an operation is executed repeatedly at a certain interval.
If you use setTimeout to implement the setInerval function, you need to regularly call yourself in the executed program. To clear a counter, you need to call different clearing methods based on the method used:
Example: tttt = setTimeout ('Hello () ', 1000 );
ClearTimeout (tttt );
Or:
Tttt = setInterval ('Hello () ', 1000 );
ClearInteval (tttt );
2. How to perform scheduled operations
For example, to regularly open the page Test. asp (of course, Test. asp can be used to read the database and generate a static page ......) Copy codeThe Code is as follows: <script language = "JavaScript" type = "text/javascript">
<! --
Function hello (){
Window. open ('HTTP: // www.jb51.net ')
}
Window. setTimeout (hello (), 5000 );
// -->
</Script>

Disadvantage: to open the page in a browser, you cannot close it.
Iii. Timing components written by ASP using VB
There are no timer statements such as setTimeout in ASP. We need to use ASP components to solve this problem. Similarly, we can use VB6 for compilation. For detailed operation methods, refer
In the previous component compilation procedure, to suspend a thread, we need to use the WIN32API function Sleep to create an Active Dll project named Timer,
Class Name: sleep.
Sleep, The WIN32API function, can be found in the API text browser of VB6.
Now the program for the sleep class is as follows. This component program is very simple and I will not explain it much.Copy codeThe Code is As follows: Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private m_set As Long
Public Property Get setup () As Long
Setup = m_set
End Property
Public Property Let setup (strset As Long)
M_set = strset
End Property
Public Function Sleeptime ()
Sleep (setup)
End Function

Compile it and generate the timer. dll component dll. If you do not write the vbprogram, you can also find timer. dll in the downloaded file package.
This file. Copy it to the windows directory and enter in MS-DOS Mode
C: \ windows \ regsvr32 timer. dll
You can also use this scheduled component to complete component registration.
Now we will describe the ASP calling file by column. Let's see how to use this component.
* Timer ApplicationCopy codeThe Code is as follows: <Title> timer application (From: Http: // www.jb51.net) </title>
<Head>
</Head>
<Body>
<%
'This is the script execution time. The default value is 90 seconds. It needs to be modified a little longer. Otherwise, the program will be interrupted after 90 seconds. '3600 is one hour.
Server. ScriptTimeOut = 3600
Set obj = server. createobject ("timer. sleep ")
'Parameter 1000 indicates that the thread is suspended for one second and can be set as needed
Obj. setup = 1000
Do while true
  
Obj. sleeptime
'Perform scheduled operations,
If Not Response. IsClientConnected Then
Set obj = nothing
Session. abandon
End If
Loop
%>
</Body>
</Html>

Advantage: here we just use VB to write a test dll, but VB can certainly write a regular execution operation in the dll.
Disadvantage: The dll written by VB may take advantage of resources.
4. I personally think it is the best way to work with the scheduled operations of computer tasks.
In my opinion, this is the best way to implement scheduled operations.
Is to first write the page on the server for scheduled operations, such as Test. asp
Then write a vbs file, as shown below:Copy codeThe Code is as follows: Dim IE
Set IE = CreateObject ("InternetExplorer. Application ")
'Run your URL
Ie. navigate ("http://www.jb51.net ")
Ie. visible = 1
'Clean up...
Set IE = Nothing

1. You can use the "Task Plan" on the server"
2. You can also use the "Task Scheduler" on the client"
Refer to the http://www.pclala.com/Pc/Skill/200851912807.Html for specific use of the Task Scheduler
Advantages and disadvantages: The Test. asp page will pop up regularly, but there is a solution, that is, to add the timed close code on the Test. asp page:Copy codeThe Code is as follows: <script LANGUAGE = "JavaScript">
<! --
SetTimeout ('window. close (); ', 500 );
// -->
</Script>

To sum up, due to the current restrictions on some web pages, it is difficult to perform regular operations. However, after many verification attempts, I found that the fourth method is undoubtedly the best, the most worry-free.

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.