Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 21st, 2006, 10:08 PM
Authorized User
 
Join Date: Jan 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default how and when does Sub application_start start?

I have built the following code in my global.asax code

My question is how and when does the Sub application_start know when to start?
What must I do to trigger it to start and send an email?



Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application is started
        Dim myConnection As New SqlConnection(ConfigurationSettings.AppSettings("c onnectionString"))
        myConnection.Open()
        '2. Create the command object, for the query
        Const strSQL As String = "Select LastUpdated, ProductId from products "
        Dim objCmd As New SqlCommand(strSQL, myConnection)
        Dim objDR As SqlDataReader
        objDR = objCmd.ExecuteReader()
        While (objDR.Read)
            'look the code is looking for DATETIME .. but it found NULL values
            'need this code to keep from getting errors if a null is found
            'we need to put some check for nulls
            If (Not (objDR("LastUpdated") Is DBNull.Value)) Then

                If (Date.Compare(objDR("LastUpdated"), Today.Date) = 0) Then
                    Dim newMail As New MailMessage
                    newMail.From = "[email protected]" '' this is the From Address
                    newMail.To = "[email protected]" '' this is TO Address
                    newMail.Subject = "Change in Product Rate"
                    newMail.Body = " Dear Ken, " & _
                    "Please review attached email for product ID: " & objDR("ProductID") & _
                    "Thank you," & _
                    "Kenn()"
                End If
            End If

        End While
        myConnection.Close() 'Close the connection

    End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Don't know where to start......... Geneine Bugg BOOK: Beginning ASP 3.0 0 December 20th, 2006 12:00 PM
What we need before getting start? seangrattana BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 June 7th, 2006 09:57 PM
start.com david_ste BOOK: Professional Ajax ISBN: 978-0-471-77778-6 3 March 27th, 2006 06:22 AM
From where to start ? eagle_y2j Intro Programming 1 March 21st, 2006 07:16 PM
declare connectionobject in application_Start met somnath.kartic ASP.NET 1.0 and 1.1 Basics 1 January 16th, 2006 05:14 PM





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