Click here to Skip to main content
15,920,896 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Daaah!! ExecuteScalar always throws an exception!! Pin
leppie6-Oct-02 11:27
leppie6-Oct-02 11:27 
GeneralRe: Daaah!! ExecuteScalar always throws an exception!! Pin
Paul Watson6-Oct-02 21:19
sitebuilderPaul Watson6-Oct-02 21:19 
GeneralRe: Daaah!! ExecuteScalar always throws an exception!! Pin
Rickard Andersson207-Oct-02 1:54
Rickard Andersson207-Oct-02 1:54 
GeneralRe: Daaah!! ExecuteScalar always throws an exception!! Pin
Paul Watson6-Oct-02 21:31
sitebuilderPaul Watson6-Oct-02 21:31 
GeneralRe: Daaah!! ExecuteScalar always throws an exception!! Pin
Rickard Andersson207-Oct-02 1:59
Rickard Andersson207-Oct-02 1:59 
GeneralRe: Daaah!! ExecuteScalar always throws an exception!! Pin
Jörgen Sigvardsson7-Oct-02 7:20
Jörgen Sigvardsson7-Oct-02 7:20 
GeneralRe: Daaah!! ExecuteScalar always throws an exception!! Pin
Rickard Andersson207-Oct-02 9:04
Rickard Andersson207-Oct-02 9:04 
GeneralFill in label.text from Page_Load... Pin
Ray Cassick6-Oct-02 5:44
Ray Cassick6-Oct-02 5:44 
I am loosing my mind here and want to make sure that I am not simply trying to do somehting that can't be done, allthough I can't belive that it can't be done really.

Problem:

I want to keep a simple counter on my website that tracks how many people are logged in. The value of this counter should be placed onto a label control when a page is loaded.

Proposed Solution:

I have this code in my global.asax file...

Public Class Global
    Inherits System.Web.HttpApplication

    Protected Shared m_ActiveUsers As Integer

#Region " Component Designer Generated Code "

    Public Sub New()
        MyBase.New()

        InitializeComponent()

    End Sub

    Private components As System.ComponentModel.IContainer

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
    End Sub

#End Region

    Public Shared ReadOnly Property ActiveUsers() As Integer
        Get
            Return m_ActiveUsers

        End Get

    End Property

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        Application.Lock()
        m_ActiveUsers = 0
        Application.UnLock()

    End Sub

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        Application.Lock()
        m_ActiveUsers = m_ActiveUsers + 1
        Application.UnLock()

    End Sub

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires at the beginning of each request
    End Sub

    Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires upon attempting to authenticate the use
    End Sub

    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when an error occurs
    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        Application.Lock()
        m_ActiveUsers = m_ActiveUsers - 1
        Application.UnLock()

    End Sub

    Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application ends
    End Sub

End Class


I have this code in my WebForm.aspx.vb file

Private Sub Page_Load(ByVal sender As System.Object,_
                           ByVal e As System.EventArgs) Handles MyBase.Load

        lblVisitors.Text = Global.ActiveUsers.ToString + " Visitors"

End Sub


The problem is that the label contents are ALWAYS blank!Mad | :mad:

Any ideas out there as to what I am doing wrong?

Help me please before I decide to do something drastic! OMG | :OMG:
GeneralRe: Fill in label.text from Page_Load... Pin
Ray Cassick7-Oct-02 4:09
Ray Cassick7-Oct-02 4:09 
GeneralEfficiency Pin
Paul Riley6-Oct-02 4:21
Paul Riley6-Oct-02 4:21 
GeneralRe: Efficiency Pin
leppie6-Oct-02 5:39
leppie6-Oct-02 5:39 
GeneralRe: Efficiency Pin
Paul Riley6-Oct-02 5:53
Paul Riley6-Oct-02 5:53 
GeneralRe: Efficiency Pin
Paul Riley6-Oct-02 6:31
Paul Riley6-Oct-02 6:31 
GeneralRe: Efficiency Pin
leppie6-Oct-02 6:42
leppie6-Oct-02 6:42 
GeneralRe: Efficiency Pin
Paul Riley6-Oct-02 6:48
Paul Riley6-Oct-02 6:48 
GeneralRe: Efficiency Pin
leppie6-Oct-02 7:48
leppie6-Oct-02 7:48 
GeneralRe: Efficiency Pin
Paul Riley6-Oct-02 9:01
Paul Riley6-Oct-02 9:01 
GeneralRe: Efficiency Pin
leppie6-Oct-02 9:23
leppie6-Oct-02 9:23 
GeneralRe: Efficiency Pin
Andy Smith7-Oct-02 10:36
Andy Smith7-Oct-02 10:36 
GeneralPaging results Pin
User 98855-Oct-02 8:08
User 98855-Oct-02 8:08 
GeneralRe: Paging results Pin
Paul Riley5-Oct-02 8:15
Paul Riley5-Oct-02 8:15 
GeneralRe: Paging results Pin
User 98855-Oct-02 8:43
User 98855-Oct-02 8:43 
GeneralRe: Paging results Pin
User 98855-Oct-02 15:35
User 98855-Oct-02 15:35 
GeneralResizing TextArea Pin
leppie5-Oct-02 3:17
leppie5-Oct-02 3:17 
GeneralRe: Resizing TextArea Pin
Paul Riley5-Oct-02 4:53
Paul Riley5-Oct-02 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.