Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Global.asax Problem

Global.asax Problem

Scheduled Pinned Locked Moved ASP.NET
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sivaram praveen
    wrote on last edited by
    #1

    If Application("TipDate") <> Today() Then Application("TipDate") = Today() If Not IsNumeric(Application("TipNumber")) Then Application("TipNumber") = 1 Else Application("TipNumber") = Application("TipNumber") + 1 End If End If I have given the above code in the page and i want to store Application("TipNumber") and it has to increment daily depending up the Date Value. So, i have placed the Appliaction("TipNumber")=1 in Appliaction_Start of Global.asax but when ever the appliaction is running TipNumber is initialised to 1 only but not incrementing? Please help me in solving this problem

    J 1 Reply Last reply
    0
    • S sivaram praveen

      If Application("TipDate") <> Today() Then Application("TipDate") = Today() If Not IsNumeric(Application("TipNumber")) Then Application("TipNumber") = 1 Else Application("TipNumber") = Application("TipNumber") + 1 End If End If I have given the above code in the page and i want to store Application("TipNumber") and it has to increment daily depending up the Date Value. So, i have placed the Appliaction("TipNumber")=1 in Appliaction_Start of Global.asax but when ever the appliaction is running TipNumber is initialised to 1 only but not incrementing? Please help me in solving this problem

      J Offline
      J Offline
      John ph
      wrote on last edited by
      #2

      This logic probably won't work since the Application_Start event is fired only once when the application starts, Not on everyday basis.

      Regards
       - J O H N -


      S 1 Reply Last reply
      0
      • J John ph

        This logic probably won't work since the Application_Start event is fired only once when the application starts, Not on everyday basis.

        Regards
         - J O H N -


        S Offline
        S Offline
        sivaram praveen
        wrote on last edited by
        #3

        Thanks for ur reply but if i want it in daily basis how to do the coding? pls help me

        J M 2 Replies Last reply
        0
        • S sivaram praveen

          Thanks for ur reply but if i want it in daily basis how to do the coding? pls help me

          J Offline
          J Offline
          John ph
          wrote on last edited by
          #4

          Could you provide some more detail about what exactly is the requirement?

          Regards
           - J O H N -


          S 1 Reply Last reply
          0
          • S sivaram praveen

            Thanks for ur reply but if i want it in daily basis how to do the coding? pls help me

            M Offline
            M Offline
            Malcolm Smart
            wrote on last edited by
            #5

            You need to persist the value somewhere, ie a database, along with the datetime it was written. Then, perhaps in an onsession event, read this value from the database, compare the date it was written with 'todays' date, and update if necessary. If you don't persist the value, if you site ever goes down, or you modify the webconfig, or the process gets recycled for any reason, you will lose this value.

            "More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF

            "This time yesterday, I still had 24 hours to meet the deadline I've just missed today."

            1 Reply Last reply
            0
            • J John ph

              Could you provide some more detail about what exactly is the requirement?

              Regards
               - J O H N -


              S Offline
              S Offline
              sivaram praveen
              wrote on last edited by
              #6

              Application("TipNumber") = 1 If Application("TipDate") <> Today() Then Application("TipDate") = Today() If Not IsNumeric(Application("TipNumber")) Then Application("TipNumber") = 1 Else Application("TipNumber") = Application("TipNumber") + 1 End If End If Dim cmd As SqlDataAdapter = New SqlDataAdapter("Select Thought From Thoughts_Tbl " & "Where id = " & Application("TipNumber"), Con) cmd.Fill(_dataSet, "TheTip") If _dataSet.Tables("TheTip").Rows.Count = 0 Then Application("TipNumber") = 1 cmd = New SqlDataAdapter("Select Thought From Thoughts_Tbl " & "Where id = " & Application("TipNumber"), Con) cmd.Fill(_dataSet, "TheTip") End If lbl_Title1.Text = "Thought of the Day :" lbl_ThoughtText.Text = _dataSet.Tables("TheTip").Rows(0).Item("Thought") This is the actual code where i'm check the date with today's day if it matches and the TipNumber is not numeric it wil take first statement Application("TipNumber") = 1 or if TipNumber is numeric i.e having some number, it wil be incremented in else part Application("TipNumber") = Application("TipNumber") + 1 but TipNumber which is incrementing is not saving? Now how to save TipNumber n incrementing it and get the next "TipOfDay" from database? Pls help me with some solution

              J 1 Reply Last reply
              0
              • S sivaram praveen

                Application("TipNumber") = 1 If Application("TipDate") <> Today() Then Application("TipDate") = Today() If Not IsNumeric(Application("TipNumber")) Then Application("TipNumber") = 1 Else Application("TipNumber") = Application("TipNumber") + 1 End If End If Dim cmd As SqlDataAdapter = New SqlDataAdapter("Select Thought From Thoughts_Tbl " & "Where id = " & Application("TipNumber"), Con) cmd.Fill(_dataSet, "TheTip") If _dataSet.Tables("TheTip").Rows.Count = 0 Then Application("TipNumber") = 1 cmd = New SqlDataAdapter("Select Thought From Thoughts_Tbl " & "Where id = " & Application("TipNumber"), Con) cmd.Fill(_dataSet, "TheTip") End If lbl_Title1.Text = "Thought of the Day :" lbl_ThoughtText.Text = _dataSet.Tables("TheTip").Rows(0).Item("Thought") This is the actual code where i'm check the date with today's day if it matches and the TipNumber is not numeric it wil take first statement Application("TipNumber") = 1 or if TipNumber is numeric i.e having some number, it wil be incremented in else part Application("TipNumber") = Application("TipNumber") + 1 but TipNumber which is incrementing is not saving? Now how to save TipNumber n incrementing it and get the next "TipOfDay" from database? Pls help me with some solution

                J Offline
                J Offline
                John ph
                wrote on last edited by
                #7

                Having this Data in the Application Variable is pointless. Application_Start Event is not meant for this. This will not serve your purpose. Why don't you have a Date Column to the Thought's Table and fetch the Tip based on the Date. I think this would be the appropriate solution to the given problem.

                Regards
                 - J O H N -


                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups