Periodically running asp page with timer

Discussion in 'ASP General' started by Bill, Jul 28, 2003.

  1. Bill

    Bill Guest

    I have an asp page that will be updating the data from one database
    into my sql server database every 3 hours. I'd like to write code that
    will tell the page to automatically run every three hours. How do I do
    this?

    Thanks,

    Bill
    Bill, Jul 28, 2003
    #1
    1. Advertising

  2. Bill

    Ray at Guest

    Change to VBS and schedule with AT.
    http://www.aspfaq.com/2143

    Ray at home

    --
    Will trade ASP help for SQL Server help


    "Bill" <> wrote in message
    news:...
    > I have an asp page that will be updating the data from one database
    > into my sql server database every 3 hours. I'd like to write code that
    > will tell the page to automatically run every three hours. How do I do
    > this?
    >
    > Thanks,
    >
    > Bill
    Ray at, Jul 28, 2003
    #2
    1. Advertising

  3. "Bill" <> wrote in message
    news:...
    > I have an asp page that will be updating the data from one database
    > into my sql server database every 3 hours. I'd like to write code that
    > will tell the page to automatically run every three hours. How do I do
    > this?
    >
    > Thanks,
    >
    > Bill

    http://www.aspfaq.com/show.asp?id=2143
    Chris Hohmann, Jul 28, 2003
    #3
  4. "Ray at <%=sLocation%>" wrote:
    >
    > Change to VBS and schedule with AT.
    > http://www.aspfaq.com/2143


    I have a similar need**, but I also want to give certain users the ability
    to manually trigger the process. I wanted to avoid maintaining duplicate
    scripts (one ASP script for end users, one JS script for scheduling), so I
    chose one.

    How would you handle this situation, Ray?

    I chose ASP, primarily so I could provide feedback while the script runs,
    since a human user expects to see that the script is doing something. This
    bumped me right into the old "how do I schedule an ASP script" problem, and
    I initially solved it by setting up a job in SQL Server (the one that was
    receiving the updates).

    The job used MSXML (specifically, MSXML2.ServerXMLHTTP.4.0) to kick off the
    script, and it worked flawlessly until we moved the DB server from NT4 to
    Win2K. I have since found that I cannot get a scheduled task to successfully
    use the ServerXMLHTTP object on a Win2K machine.

    I can create a VBS or JScript file and launch it successfully while logged
    in, but that same script will not run as a scheduled task. Ditto for
    compiled executables and (as noted previously) SQL Server jobs.

    Any suggestions, Ray?


    **In my case, I need to take a snapshot of part of a proprietary DB and
    stick it into a SQL Server DB, which is the data store for an intranet
    application. The vendor supplied us with a somewhat crude API as our only
    means of talking to their DB, and it is not flexible to talk with SQL Server
    directly.


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
    Dave Anderson, Jul 28, 2003
    #4
  5. Bill

    Ray at Guest

    You could still contain everything in a vbs file and then if you want a user
    to be able to execute the script, use WshShell object to execute the vbs
    file, if the user has permissions.

    Ray at home

    --
    Will trade ASP help for SQL Server help


    "Dave Anderson" <> wrote in message
    news:...
    > "Ray at <%=sLocation%>" wrote:
    > >
    > > Change to VBS and schedule with AT.
    > > http://www.aspfaq.com/2143

    >
    > I have a similar need**, but I also want to give certain users the ability
    > to manually trigger the process. I wanted to avoid maintaining duplicate
    > scripts (one ASP script for end users, one JS script for scheduling), so I
    > chose one.
    >
    > How would you handle this situation, Ray?
    >
    > I chose ASP, primarily so I could provide feedback while the script runs,
    > since a human user expects to see that the script is doing something. This
    > bumped me right into the old "how do I schedule an ASP script" problem,

    and
    > I initially solved it by setting up a job in SQL Server (the one that was
    > receiving the updates).
    >
    > The job used MSXML (specifically, MSXML2.ServerXMLHTTP.4.0) to kick off

    the
    > script, and it worked flawlessly until we moved the DB server from NT4 to
    > Win2K. I have since found that I cannot get a scheduled task to

    successfully
    > use the ServerXMLHTTP object on a Win2K machine.
    >
    > I can create a VBS or JScript file and launch it successfully while logged
    > in, but that same script will not run as a scheduled task. Ditto for
    > compiled executables and (as noted previously) SQL Server jobs.
    >
    > Any suggestions, Ray?
    >
    >
    > **In my case, I need to take a snapshot of part of a proprietary DB and
    > stick it into a SQL Server DB, which is the data store for an intranet
    > application. The vendor supplied us with a somewhat crude API as our only
    > means of talking to their DB, and it is not flexible to talk with SQL

    Server
    > directly.
    >
    >
    > --
    > Dave Anderson
    >
    > Unsolicited commercial email will be read at a cost of $500 per message.

    Use
    > of this email address implies consent to these terms. Please do not

    contact
    > me directly or ask me to contact you directly for assistance. If your
    > question is worth asking, it's worth posting.
    >
    >
    Ray at, Jul 28, 2003
    #5
  6. > I have a similar need**, but I also want to give certain users the ability
    > to manually trigger the process. I wanted to avoid maintaining duplicate
    > scripts (one ASP script for end users, one JS script for scheduling), so I
    > chose one.
    >
    > How would you handle this situation, Ray?


    Have the VBS script run on a schedule, and in the cases where you need to
    trigger it from ASP, use WSH to fire off cscript, or see
    http://www.aspfaq.com/2059 (of course the ASP page will have to be reached
    through authentication, or IUSR given sufficient privileges).

    You could also call MSXML from a scheduled SQL Server job, and call
    msdb..sp_start_job on manual occasions.
    Aaron Bertrand - MVP, Jul 28, 2003
    #6
  7. "Ray at <%=sLocation%>" wrote:
    >
    > You could still contain everything in a vbs file and then if
    > you want a user to be able to execute the script, use WshShell
    > object to execute the vbs file, if the user has permissions.


    As noted originally, this precludes the possibility of giving feedback to
    the user other than an ambiguous "job started" message. This is a problem
    for a couple of reasons.

    As you may recall the script reads the vendor's DB via the vendor's API.
    What I didn't mention is that I have to use this extraction method for
    several sets of data in the vendor's DB, and the API cannot read from two of
    them simultaneously. In fact, if an attempt is made to read from one set
    while another is being read from, both processes are killed. This is the
    primary reason we mirror the data on SQL Server, since it makes simultaneous
    searches in multiple data sets impossible (secondary: speed of retrieval,
    which is on the order of .1 second per record returned, tertiary:
    readability of web scripts due to the horrible API).

    This is why I like to present feedback to the web user -- I spit out a bit
    of output every 100 records, so he can see how far the job has progressed.
    He can see when the job finishes and can run the next one. I suppose I can
    prevent two jobs from running concurrently, but I'm certain the API doesn't
    allow me to check, so I'll have to flag the start/finish events in SQL
    Server**.

    I have actually considered using the third suggestion here:
    http://www.aspfaq.com/show.asp?id=2143, since this is a very high-traffic
    application. I will have to give it some consideration.



    **I already track job events for reporting purposes, so this isn't a great
    burden, but I'm hesitant to use such abstracted logic, since there are
    obviously situations that could arise (if the web server or SQL Server box
    crashed in the middle of the job, for example) that would cause the job to
    abort without an appropriate flag in the DB. Job initiation logic requiring
    the completion of already started jobs would then leave me in a state that
    disallows *any* jobs from running until the DB entry is cleared.


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
    Dave Anderson, Jul 28, 2003
    #7
  8. "Aaron Bertrand - MVP" wrote:
    >
    > Have the VBS script run on a schedule, and in the cases where you
    > need to trigger it from ASP, use WSH to fire off cscript, or see
    > http://www.aspfaq.com/2059 (of course the ASP page will have to
    > be reached through authentication, or IUSR given sufficient
    > privileges).


    I think my response to Ray addresses the above. However...

    > You could also call MSXML from a scheduled SQL Server job, and
    > call msdb..sp_start_job on manual occasions.


    Tried that already. I keep getting "access denied" errors when attempting to
    use MSXML in a job. If you have any insight there, I'd be grateful, since
    I'd be home free. My jobs were set up long ago, and only stopped working
    when the DB moved from an NT4 box to a Win2K one.


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
    Dave Anderson, Jul 28, 2003
    #8
  9. > Tried that already. I keep getting "access denied" errors when attempting
    to
    > use MSXML in a job. If you have any insight there, I'd be grateful, since
    > I'd be home free. My jobs were set up long ago, and only stopped working
    > when the DB moved from an NT4 box to a Win2K one.


    Well, who does SQL Server run as, local system account, a domain account,
    ....? Same question for SQL Server agent. This user must have permission to
    instantiate the MSXML object, and I doubt a restricted user like local
    system account has such permission (in fact this is why xp_cmdshell also
    often fails when called from a job). If you set SQL Server Agent to log on
    as a specific user, e.g. with local admin rights, then it should be able to
    call COM objects no problem...
    Aaron Bertrand [MVP], Jul 29, 2003
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. H @ Q
    Replies:
    0
    Views:
    458
    H @ Q
    May 31, 2004
  2. =?Utf-8?B?U3RldmU=?=

    Activate ASP.NET periodically

    =?Utf-8?B?U3RldmU=?=, Feb 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    433
    John Timney \(Microsoft MVP\)
    Feb 25, 2004
  3. =?Utf-8?B?Q2hyaXN0aWFu?=
    Replies:
    1
    Views:
    4,869
    Brock Allen
    Apr 29, 2005
  4. Simon

    page timer, or redirect timer

    Simon, Nov 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    11,203
    Bruce Barker
    Nov 4, 2005
  5. paul
    Replies:
    4
    Views:
    678
    Robert.Spilleboudt
    Apr 10, 2008
Loading...

Share This Page