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 に答える