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 :)