p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Databases (http://p2p.wrox.com/forumdisplay.php?f=62)
-   -   Autofire database query (http://p2p.wrox.com/showthread.php?t=2991)

hoffmann August 20th, 2003 10:55 AM

Autofire database query
 
I have created a query that needs to run once a day to send reminder notices to everyone that is scheduled to work a service in 5 days. All of the code in the page works when I fire the page, but I need the page to fire once on its own at some specific time (i.e. 00:00:01). How do I get the server to fire the page without user intervention?

Rich Hoffmann


Imar August 20th, 2003 11:57 AM

Hi Rich,

What kind of database are you using? For example, SQL Server supports scheduling of Stored Procedures.

If you're using another kind of database, let me know. There are other ways to schedule stuff like this too.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

hoffmann August 20th, 2003 12:30 PM

Access 2000, Front Page 2002, I am using JavaScrip ASP code to create the SQL command and generate emails to each person that is returned by the query.


Imar August 20th, 2003 12:49 PM

Hi Rich,

Well, in that case you may want to take a look at .vbs or .jse files

These files are more or less the same as ASP pages (they use the same scripting language, like VBScript or JavaScript) but they run at the desktop, and not through a server.

You can use more or less the same code and objects (Recordsets, Connections, etc.) except for ASP intrinsic stuff, like Response and browser related stuff, like alert(Use WScript.Echo instead).

The good thing about a .vbs file is that it's very easy to schedule its execution through the Windows Scheduled Task feature.

All you need to do to get going is create a text file, rename it with a .vbs extension and open it in Notepad. You don't need <% and %> delimiters, you can place the VBScript or JScript right inside the file. Theoretically, you could get away with copying and pasting ASP code.

Useful links:

http://msdn.microsoft.com/library/de...ng11132000.asp
http://msdn.microsoft.com/library/de...ting061499.asp

Let me know if you need more advice....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

hoffmann August 20th, 2003 01:31 PM

I really need this function to operate on the server. Is this not possible?


Imar August 20th, 2003 02:48 PM

Well, it *can* operate on the server, as you can save and schedule the file there.

The alternative is to schedule Internet Explorer to pop open at certain times and request the page. Pretty messy solution.

By creating a script file, you can stick to the same programming knowledge you use for your ASP pages. IMO, it's a nice and clean way to run stuff at the server at certain intervals.

I have been using scripts like this for years to both read and send e-mail from automated accounts and it works perfect.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

hoffmann September 3rd, 2003 03:00 PM

Sorry for the long delay in this response. Been on other things lately.

I have read the 2 articles that you sent me and they both flew right over my head. Can you send me an example of code you have written that resides on the host and fires a single .asp file once a day?

I really appreciate the help!

Rich


Imar September 5th, 2003 01:28 PM

Hi Rich,

Late response here as well as I was quite busy.

If you insist on executing an ASP page in your browser, create a small .vbs file that uses the Wscript.Run method to fire up your browser and pass it the URL you want to open. However, I recommend not using this method. It's pretty difficult getting rid of open browser Windows. If you return to your server, you may have loads of open Explorer Windows.

IMO, the preferred way to do this is to copy your ASP code to a .vbs file, remove / modify any code relating to Response / Request etc. objects and the script should run fine.

Take a look at this article for a simple example of a .vbs file. If you look at the second method, you'll find the code to be exactly the same as in an ASP page.

Search Google for Schedule ASP page and you'll find loads of other useful examples.

There also seems to be a commercial application that can handle this. It's available at http://www.script-schedule.com/. I have never tried it, so I don't know if it will do what they say it does.

HtH,

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.


All times are GMT -4. The time now is 11:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.