When there is only one user, the page behaves. When multiple users are accessing the page, each user's Timer1 is causing Table1's column1 (boolean) to switch to False. The more users, the crazier the chaos.
I have a database trigger (triggerX) on another table (TableX) for when every time a certain TableX column gets updated, Table1's column1 gets set to True. The problem is that when multiple users, this column1 gets switch to False before it is time to become False for another user. One user's False spoils another user's True. The more users, the more False column1 becomes.
How can I do this so that users are not checking and updating the same Table1's column1's row 1?
<asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional"
ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Timer runat="server" id="Timer1" OnTick="Timer1_Tick" Interval="5000">
</asp:Timer>
<Label id="Label1">
</ContentTemplate>
</asp:UpdatePanel>
And the timer vb code that gets done every 5 seconds..
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Dim ds As DataSet
ds = fillDataset("SELECT column1 FROM [Table1]", connstring, False)
If (ds.Tables(0).Rows(0).Item("column1") = True) Then
Using sqlCon = New SqlConnection(connstring)
sqlCon.Open()
Dim sqlText = "UPDATE Table1 SET column1='False' WHERE column1 IS NOT NULL;"
Dim cmd = New SqlCommand(sqlText, sqlCon)
cmd.ExecuteNonQuery()
End Using
UpdatePanel1.Update()
End If
End Sub
I would store the last date/time your record was changed. When a user loads the results, store that date/time in a hidden field so its posted back and can be compared to the current last date/time. This will remove your chaos and allow multiple users to update appropriately based on their last results displayed.
Alternatively, you could store a 'version' number on the record for the same purpose. Basically, any progressive value will be better than a yes/no system.