Re: Creating a Trigger on Access
- From: "Alex" <iamalex84@xxxxxxxxx>
- Date: 8 Jun 2006 14:23:23 -0700
Thank you very much. I have customized and created the procedure. One
more problem though... How do I use it in ASP? I have never worked
with stored procedures before. I'm having trouble with passing the
username and password to it. Also, how do I retrieve the returned
values? Also, is there a way to grab the current value before it is
updated?
Dan Guzman wrote:
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.
.
- Follow-Ups:
- Re: Creating a Trigger on Access
- From: Dan Guzman
- Re: Creating a Trigger on Access
- Prev by Date: Remote SSIS Access
- Next by Date: Re: Creating a Trigger on Access
- Previous by thread: Remote SSIS Access
- Next by thread: Re: Creating a Trigger on Access
- Index(es):
Relevant Pages
|