SQL to trigger an ASP file

  • Good day! I wanted to know if it's possible for SQL to trigger/fire an ASP file once it sees that the timeToSend field in my database table is equal to my computer's/system's time?

    Thanks and I'm hoping for your answers!

  • I think that you are taking the wrong approach. It's not a good idea to use sql server to initialise another application in this scenario.

    I would think that you want something like a filewatcher running that will then call an asp page. Have a look around the net and I'm sure you will see that someone's already achieved this.

     


    ------------------------------
    The Users are always right - when I'm not wrong!

  • Triggers do not monitor data.  They only run on table for an insert, update, or delete transaction.

    Can you explain what the table holds?

    Is it a table that holds a single row of configuration data or is it the "timetoSend" column hold values for multiple rows?

  • Also, what does the ASP file do?

    Maybe it's something that can be done in a SQL job.

    I know where you're coming from.  When I was a beginner and only felt comfortable writing ASP, I did something similar:  When all you have is a hammer, everything looks like a nail.  But now I would never write an automatic "run in the background" program in ASP.  There are lots of better tools for it.

  • Hi,

    I've implemented something similar to what you're asking for.  I use the Windows Scheduler on our server to launch internet explorer with the URL of an ASP page every day.

    That ASP page looks in our database to see if anything needs doing, then does it!

    Good luck!

    - Chris

  • See if this will work, you might have to twaek some code (BW, thisis not my code :-))

     

     

     

    -------------------------------------------------------------------

    -- ValidateURL.sql

    -- http://sqljunkies.com/WebLog/amachanic/articles/ValidateURL.aspx

    -------------------------------------------------------------------

    -- Select ObjectProperty(Object_id('ValidateURL'),'IsScalarFunction')

    If (Select ObjectProperty(Object_id('ValidateURL'),'IsScalarFunction')) = 1

       Begin

           Drop FUNCTION dbo.ValidateURL

           Print 'Dropped  FUNCTION dbo.ValidateURL'

       End

    go

    /*

    SET NOCOUNT ON

    SELECT dbo.ValidateURL('http://www.microsoft.com/sql')         -- 1

    SELECT dbo.ValidateURL('http://www.XMLisNOTaMAGICbullet.com/') -- 0

    */

    Print 'Creating FUNCTION dbo.ValidateURL'

    go

    CREATE FUNCTION dbo.ValidateURL(@URL VARCHAR(8000))

    RETURNS BIT

    AS

    BEGIN

     DECLARE @Object INT

     DECLARE @Return TINYINT

     DECLARE @Valid BIT SET @Valid = 0 --default to false

            Select  @URL = Ltrim(Rtrim(ISNULL(@URL,'')))

            If @URL = ''

               Begin

                   Select @Valid = 0

                   Return @Valid

               End

     

     --create the XMLHTTP object

     EXEC @Return = sp_oacreate 'MSXML2.ServerXMLHTTP.3.0', @Object OUTPUT

     IF @Return = 0

     BEGIN

      --define method

      DECLARE @Method VARCHAR(350)

      SET @Method = 'open("GET", "' + @URL + '", false)'

      --Open the connection

      EXEC @Return = sp_oamethod @Object, @Method

     

      IF @Return = 0

      BEGIN

       --SEND the request

       EXEC @Return = sp_oamethod @Object, 'send()'

      END

     

      IF @Return = 0

      BEGIN

       DECLARE @Output INT

       EXEC @Return = sp_oamethod @Object, 'status', @Output OUTPUT

     

       IF @Output = 200

       BEGIN

        SET @Valid = 1

       END

      END

     END

     

     --destroy the object

     EXEC sp_oadestroy @Object

     RETURN (@Valid)

    END

    go


    paul

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply