Hello all,
I have this SP that is throwing an error like this:
Msg 8114, Level 16, State 5, Procedure up_get_usersPassword, Line 0
Error converting data type varchar to int.
The SP is below. I am not sure what is going on. If I grab everything
from the declarations to the first END and run it, replacing my email
address for the @Email in the first SET, everything works fine. But when
I run exec up_get_usersPassword 0,'[EMAIL PROTECTED]' I get the error.
Anyone see what could be wrong?
-- Add the parameters for the stored procedure here
@Email varchar(100) = NULL,
@Users_id int = 0
AS
-- Insert statements for procedure here
IF @Users_id = 0 AND @Email IS NOT NULL
BEGIN
-- Try to log in the user
IF EXISTS (SELECT Users_id FROM Users WHERE Email = @Email)
BEGIN
--Create the variables for the random number
generation
DECLARE @Userid INT;
DECLARE @Random VARCHAR(5);
DECLARE @Upper INT;
DECLARE @Lower INT
--This will create a random number between 1000
and 9999
SET @Userid = (SELECT Users_id FROM Users WHERE Email =
@Email)
SET @Lower = 1000 --The lowest random number
SET @Upper = 9999 --The highest random number
SELECT @Random = ROUND(((@Upper - @Lower
-1)*Rand() + @Lower),0)
UPDATE Users
SET Password = @Random
WHERE Users_id = @Userid
SELECT Users.Password
FROM Users
WHERE Users_id = @UserID
END
ELSE
SELECT 0 as Users_id, 'Invalid email address, account not
found.' as Message
END
ELSE
SELECT Users.Password
FROM Users
WHERE Users_id = CASE WHEN @Users_id = 0 THEN Users_id ELSE
@Users_id END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Get involved in the latest ColdFusion discussions, product
development sharing, and articles on the Adobe Labs wiki.
http://labs/adobe.com/wiki/index.php/ColdFusion_8
Archive: http://www.houseoffusion.com/groups/SQL/message.cfm/messageid:3002
Subscription: http://www.houseoffusion.com/groups/SQL/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6