I have created one sql procedure to return password associated with user name.
SQL Procdure:
USE [C:\INETPUB\WWWROOT\ADDMARKER\MAP\MAP\APP_DATA\ASPNETDB.MDF]
GO
/****** Object: StoredProcedure [dbo].[aspnet_Membership_EmailPassword] Script Date: 10/18/2012 15:32:02 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[aspnet_Membership_EmailPassword]
-- Add the parameters for the stored procedure here
(
@UserName nvarchar(256),
@PasswordReturn nvarchar(128) out
)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
DECLARE @UserId uniqueidentifier
DECLARE @Password nvarchar(128)
DECLARE @Return_Password nvarchar(256)
DECLARE @IsLockedOut bit
DECLARE @ErrorCode int
SET @ErrorCode = 0
DECLARE @TranStarted bit
SET @TranStarted = 0
SET NOCOUNT ON;
IF( @@TRANCOUNT = 0 )
BEGIN
BEGIN TRANSACTION
SET @TranStarted = 1
END
ELSE
SET @TranStarted = 0
SELECT @UserId = u.UserId,
@Password = m.Password,
@IsLockedOut = m.IsLockedOut
FROM dbo.aspnet_Users u, dbo.aspnet_Membership m WITH ( UPDLOCK )
WHERE u.UserId = m.UserId AND
LOWER(@UserName) = u.LoweredUserName
IF ( @@rowcount = 0 )
BEGIN
SET @ErrorCode = 1
END
IF( @IsLockedOut = 1 )
BEGIN
SET @ErrorCode = 99
END
IF(Not( @ErrorCode = 0) )
set @PasswordReturn = 'Error in search'
ELSE
set @PasswordReturn = @Password
RETURN @PasswordReturn
END
I am getting error
“Msg 245, Level 16, State 1, Procedure aspnet_Membership_EmailPassword, Line 59
Conversion failed when converting the nvarchar value ‘egt1egt’ to data type int.”
On execution of that procedure.
Please can any one help?
Thanks
Returncan only return an int which is the return value of the procedure.The output parameter will be automatically returned when you exit the procedure, so remove the line
See http://msdn.microsoft.com/en-us/library/59x02y99(v=vs.71).aspx for a detailed explanation of the difference between output parameters and the return value