how to change the columns data automatically in sql server tables based on the changing day?
I am creating bank application project in this project i am using sql server2008
, vs2010(.net)
now my problem is account login page, user enter 3 time wrong password account is blocked today only , next day(date changing) automatically activate that acc开发者_如何学Count how to write the code pls help me.
Thank u hemanth
Have a column AccountLockedUntil
(which is a DATETIME NULL or similar), and set it to the following midnight when the threshold is reached. When validating the credentials, check to make sure it is either NULL or that the current time is past whatever is stored there. When the user logs in successfully, set it to NULL.
To keep track of the number of failed logins, I would have a complete audit log table (logging both successful and failed attempts) plus a corresponding field on the user accounts table which counts the current number of failed logins. Strictly speaking this is a violation of database normalization, but the audit table will get huge very quickly so you don't want to have to search through that more than necessary, and certainly not on every login attempt.
Create a table called LoginEvents
. When a user attempts to login create an entry here (with the user id, date and a success/fail flag). When you load the log in page, check this table for three (or more) entries that have fail = true
and that have date >= today's date - 1
. If there is are three or more show them an error message saying their account is blocked.
精彩评论