User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 373,095 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,959 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 356 | Replies: 2
Reply
Join Date: Mar 2008
Posts: 19
Reputation: Elmo_loves_you is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Elmo_loves_you Elmo_loves_you is offline Offline
Newbie Poster

Help Scalar variable Error

  #1  
Mar 18th, 2008
Hello Everyone

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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2008
Posts: 20
Reputation: ravichandra is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 4
ravichandra ravichandra is offline Offline
Newbie Poster

Help Re: Scalar variable Error

  #2  
Mar 18th, 2008
Remove

RETURN @RoleTitle
and try

Good luck
Reply With Quote  
Join Date: Mar 2008
Posts: 19
Reputation: Elmo_loves_you is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Elmo_loves_you Elmo_loves_you is offline Offline
Newbie Poster

Solution Re: Scalar variable Error

  #3  
Mar 19th, 2008
Originally Posted by ravichandra View Post
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 4:48 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC