Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
Create Proc [dbo].[prcLoginv]
 (
 @Username VarChar(50),
 @UPassword varChar(50),
 @OutRes int OUTPUT
 )
 AS
set @OutRes = (SELECT count(*) FROM [dbo].Log_Users
WHERE Username = @Username And [Password] = @UPassword)
if(@OutRes = 1)


begin
set @OutRes 1--Login is Correct
end

else

begin

set @OutRes = 0  --Bad login
end
Posted
Updated 14-May-12 20:46pm
v2
Comments
Wendelius 15-May-12 2:46am    
What is the error you're getting?

If I'm interpreting the code correctly, you could be able to do the same thing with simply the following:
SQL
CREATE PROCEDURE [dbo].[prcLoginv] (
 @Username VarChar(50),
 @UPassword varChar(50),
 @OutRes int OUTPUT)
AS
   SET @OutRes = 
      (SELECT COUNT(*) 
      FROM [dbo].Log_Users
      WHERE Username   = @Username 
      AND   [Password] = @UPassword);
 
Share this answer
 
send the error you are getting..
 
Share this answer
 
Comments
2011999 15-May-12 2:53am    
Msg 102, Level 15, State 1, Procedure prcLoginv, Line 14
Incorrect syntax near '1'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900