August 2, 2011 at 9:37 am
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[EmployeeAuthentication]
(
@username Char( 25 ),
@DOB Char( 25 )
)
As
DECLARE @actualPassword Char( 25 )
IF @dob IS NOT NULL
BEGIN
SELECT @actualPassword =convert(VARCHAR(10),DOB,101) , [LName]+', '+[FName] as [fullName]
FROM [Annual_Edu_2006].[dbo].[HREMP_Adp]
Where [FullName] = @username
IF @DOB = @actualPassword
RETURN 1
else
return 0
END
else
RETURN -1
Msg 141, Level 15, State 1, Procedure EmployeeAuthentication, Line 21
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
August 2, 2011 at 9:48 am
try this
SELECT @actualPassword =convert(VARCHAR(10),DOB,101)
FROM [Annual_Edu_2006].[dbo].[HREMP_Adp]
Where [LName]+', '+[FName] = @username
Are you really going to use this to authenticate users in a production system?
August 2, 2011 at 9:50 am
yes.
August 2, 2011 at 9:50 am
or maybe this (I don't know what your tables look like!!!)
SELECT @actualPassword =convert(VARCHAR(10),DOB,101)
FROM [Annual_Edu_2006].[dbo].[HREMP_Adp]
Where fullName = @username
August 2, 2011 at 9:51 am
August 2, 2011 at 9:53 am
how about:
if exists (SELECT 1
FROM [Annual_Edu_2006].[dbo].[HREMP_Adp]
Where [LName]+', '+[FName] = @username
and convert(VARCHAR(10),DOB,101) = @DOB )
return 1
else
return 0
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
August 2, 2011 at 9:53 am
yesm
August 2, 2011 at 9:55 am
August 2, 2011 at 9:58 am
problem solved. Thx.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply