2

我想创建一个只允许同一用户进行单一登录会话的应用程序。即该用户没有并发登录。

我创建了一个存储当前登录列表的表。当用户注销或退出应用程序时,用户名将从登录表中删除。

但是当用户异常中止程序或由于应用程序崩溃时,用户名仍然留在登录列表表中。当用户再次尝试登录时,系统将拒绝他的登录,因为他的用户名仍在登录列表中。

我该如何克服这个问题?应用异常退出,如何从登录列表中删除用户名?

非常感谢您的建议。谢谢你。

4

1 回答 1

0

For any user that opens the database (via AutoExec) you might have a hidden form that runs 2 modules on a timer. The first module will "Check in" every x minutes and add a time-stamp to the login table you have created. The second will check that for every username on the table, they have an associated time-stamp within x minutes, and if not, remove them from the table.

There are probably more efficient ways to do this, but off the top of my head: add a yes/no "MarkForDeletion" column to your table so you can run an UPDATE query on any time-stamp row that is out of date. Then run a DELETE query for those rows marked for deletion.

Public Sub CheckIn()

'Code to UPDATE now() onto table where you have added the current username

End Sub

Public Sub AuditCheckIn()

'UPDATE SQL here
'DELETE SQL here

End Sub

Example of Update SQL:

----assuming you are checking in every 2 minutes
UPDATE Logins SET Logins.Deletion = -1
WHERE (((Logins.Timestamp)<=DateAdd("n",2,Now())));

Example of Delete SQL:

-----Presumably you already have this, just add:
WHERE Logins.Deletion=-1
于 2012-12-26T00:07:17.010 回答