Re: Creating a Trigger on Access
- From: "Dan Guzman" <guzmanda@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 23 May 2006 19:40:07 -0500
I don't think a 'SELECT' trigger would be a good idea since data could be
access for reasons other than login. IMHO, a stored procedure would be the
best approach since you can include other login activities, like password
validation. For example:
CREATE PROCEDURE dbo.usp_LoginUser
@UserName varchar(30),
@Password varchar(30)
AS
SET NOCOUNT ON
DECLARE @ReturnCode int
UPDATE dbo.Users
SET LastLoginTime = GETDATE()
WHERE
UserName = @UserName AND
Password = @Password
IF @@ROWCOUNT > 0
BEGIN
--indicate login success
SET @ReturnCode = 0
END
ELSE
BEGIN
--indicate login failure
SET @ReturnCode = 1
END
RETURN @ReturnCode
GO
--
Hope this helps.
Dan Guzman
SQL Server MVP
<iamalex84@xxxxxxxxx> wrote in message
news:1148414912.126785.4600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I am trying to create a trigger to update a datetime field when a user
logs in to their account. Is there a way to create a trigger that
updates a field when the table is accessed? The only other possible
way I can think of to accomplish this would be to write code that
updates a field on submit so that it trips the trigger I have to update
the time. This does not seem especially efficient, though.
.
- References:
- Creating a Trigger on Access
- From: iamalex84
- Creating a Trigger on Access
- Prev by Date: Re: who dropped my table in SQL Server?
- Next by Date: Restricting access via LAN
- Previous by thread: Creating a Trigger on Access
- Next by thread: Restricting access via LAN
- Index(es):
Relevant Pages
|