Need some help with C# and MS SQL
Posted: Wed Aug 24, 2011 4:47 am
So here is my login stored procedure. I want this stored procedure to return 2 things after the user logs in. 1 to be the user id. and 2 to be the user rank. both are ints.
How would i get that procedure to return the ID and the RoleID using c#? I'm not very good with ms sql but once i have it once. I can always refer to it later and figure out how it works and practice it more.
Code: Select all
-- =============================================
-- Author: JR Padfield
-- Create date: 8/21/2011
-- Description:
-- =============================================
ALTER PROCEDURE [dbo].[Account_Authenticate]
@Username nvarchar(50),
@Password nvarchar(50)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @ID bigint
DECLARE @RoleName varchar(30)
DECLARE @LastLogin datetime
SELECT @ID = dbo.Users.ID, @RoleName = dbo.Roles.Role, @LastLogin = LastLoginDate
FROM dbo.Users INNER JOIN dbo.Roles ON dbo.Users.RoleID = dbo.Roles.RoleID
WHERE UserName = @UserName AND Password = @Password
IF @ID IS NOT NULL
BEGIN
UPDATE Users SET LastLoginDate = GetDate() WHERE ID = @ID
SELECT dbo.Users.ID, dbo.Roles.Role, dbo.Users.IsLockedOut, dbo.Users.LockOutReason,
@LastLogin As 'LastLoginDate', dbo.Users.LastLockoutDate, dbo.Users.LastPasswordChangeDate
FROM dbo.Users
INNER JOIN dbo.Roles ON dbo.Users.RoleID = dbo.Roles.RoleID
WHERE ID = @ID
END
END