Scalar variable Error
Hello Everyone :S
I am rather new to ASP.NET. I have an SQL Server 2005 database set up. So far its quite basic with just two tables (UsersLogin, Roles). My aim is to allow users of different ranks to login to the system ie. Admin, Staff etc.
UsersLogin table holds (UserID, Username, Password, RoleID)
Roles table holds (RoleID, RoleTitle)
I have created a stored procedure that returns the roleTitle based on the username and password entered. I was thinking that this approach would enable me to direct the user to the appropriate page for their rank (in the code behind page), the code is as follows:
//-----------------------------Code Sample--------------------------------
CREATE PROCEDURE dbo.ValidateUser
/* Parameters needed to obtain data from user*/
(
@UserName VARCHAR(20) = NULL
@Password VARCHAR(20) = NULL
@RoleTitle VARCHAR(20) = NULL
)
AS
SELECT Roles.RoleTitle
FROM Roles INNER JOIN
UsersLogin ON Roles.RoleID = UsersLogin.RoleID
WHERE (UsersLogin.Username = @UserName) AND (UsersLogin.Password = @Password)
RETURN @RoleTitle
//-----------------------------END Code Sample--------------------------------
I can execute the query successfully within the design wizard and I get the result I want but I can't save the stored procedure. I am prompted with the following Error Message:
Incorrect syntax near '@Password'
Must declare the scalar variable '@UserName'
Must decalre the scalar variable '@RoleTitle'
I have spent some time reading articles and browsing other threads that have suggested using '?' but this hasnt worked.
Has anyone any ideas? Thanks in advance
Elmo :)
Elmo_loves_you
Junior Poster in Training
85 posts since Mar 2008
Reputation Points: 30
Solved Threads: 0
Remove
RETURN @RoleTitle
and try
Good luck
Thankyou very much, it worked :)
I now have my login page identifying the correct rank .... wooohooo
though thats just one of a million other things I have to do :)
Elmo_loves_you
Junior Poster in Training
85 posts since Mar 2008
Reputation Points: 30
Solved Threads: 0