<% '============================================================================= ' SUBROUTINE: AutoDeactivateExpiredNotifications ' PURPOSE: Automatically deactivate notifications where endtime has passed ' ' LOGIC: ' - Find all active notifications where endtime < NOW() (expired) ' - Set isactive = 0 for those notifications ' - This provides automatic cleanup without manual intervention ' ' RUNS: On every page load (minimal performance impact - simple UPDATE query) '============================================================================= Sub AutoDeactivateExpiredNotifications() On Error Resume Next Dim strAutoDeactivate strAutoDeactivate = "UPDATE notifications SET isactive = 0 " & _ "WHERE isactive = 1 " & _ "AND endtime IS NOT NULL " & _ "AND endtime < NOW()" objConn.Execute strAutoDeactivate On Error Goto 0 End Sub ' objConn - script-global connection object (no Dim for global scope) Session.Timeout=15 Set objConn=Server.CreateObject("ADODB.Connection") ' Old DSN connection: ' objConn.ConnectionString="DSN=shopdb;Uid=root;Pwd=WJF11sql" ' Direct MySQL ODBC connection with pooling enabled: objConn.ConnectionString="Driver={MySQL ODBC 9.4 Unicode Driver};" & _ "Server=192.168.122.1;" & _ "Port=3306;" & _ "Database=shopdb;" & _ "User=570005354;" & _ "Password=570005354;" & _ "Option=3;" & _ "Pooling=True;Max Pool Size=100;" objConn.Open set rs = server.createobject("ADODB.Recordset") ' Auto-deactivate expired notifications ' This runs on every page load to ensure notifications with past endtime are automatically disabled Call AutoDeactivateExpiredNotifications() %>