I have a strange problem. I update a flag in my database when a user is logging in.
Code:
Sub ConnectUser(ByVal userName As String)
        strUserCn = "Provider=Microsoft.jet.oledb.4.0;Data Source=" & Server.MapPath("login.MDB") & ";"
        Dim strSql As String = "update Person SET Online='Yes', LastLogin='" & CDate(Date.Now) & _
        "', Logins=" & CInt(Session("NoOfLogins") + 1) & " WHERE UserName='" & userName & "'"
        Dim objConnection As New OleDbConnection(strUserCn)
        Dim objCommand As New OleDbCommand(strSql, objConnection)
        Dim objDataReader As OleDbDataReader

        objConnection.Open()
        objCommand = New OleDbCommand(strSql, objConnection)
        objCommand.ExecuteNonQuery()
        objConnection.Close()
    End Sub
This works fine, the flag is updated and the value is 'Yes'.
But then I implement this code, for setting the value to 'No', when the user terminates the session:
Code:
Private Sub Page_Unload(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Unload
        clsUserLogin1.DisconnectUser(Session("username"))
    End Sub
where
Code:
Sub DisconnectUser(ByVal userName As String)
        strUserCn = "Provider=Microsoft.jet.oledb.4.0;Data Source=" & Server.MapPath("login.MDB") & ";"
        Dim strSql As String = "update Person SET Online='No' WHERE UserName='" & userName & "'"
        Dim objConnection As New OleDbConnection(strUserCn)
        Dim objCommand As New OleDbCommand(strSql, objConnection)
        Dim objDataReader As OleDbDataReader

        objConnection.Open()
        objCommand = New OleDbCommand(strSql, objConnection)
        objCommand.ExecuteNonQuery()
        objConnection.Close()
    End Sub
When I have logged in and investigates the value in the database I see that the value is 'No' right after I have loaded the application??? What is happening? I know that I could make a "Logout" button, but it would be great if this could work.