I've tried many solutions on stackoverflow yet not one gave me a solution, I have the following query, which passes in three parameters
using (var sqlCon = new SqlConnection(Database.ReturnDatabaseConnection()))
{
var p = new DynamicParameters();
p.Add("@EmailAddress", emailAddress);
p.Add("@UserId", SqlDbType.BigInt, direction: ParameterDirection.InputOutput);
p.Add("@UniqueId", SqlDbType.UniqueIdentifier, direction: ParameterDirection.InputOutput);
var t = sqlCon.Execute("RequestPasswordReset", p, commandType: CommandType.StoredProcedure);
var b = p.Get<Int64>("@UserId");
var c = p.Get<Guid>("@UniqueId");
}
which calls the following stored procedure
ALTER PROCEDURE RequestPasswordReset
@EmailAddress varchar(320),
@UserId bigint output,
@UniqueId UniqueIdentifier output
AS
BEGIN
SET NOCOUNT ON;
SET @UserId = (Select ISNULL(Id, NULL) from [User].[User_Profile] where EmailAddress = @EmailAddress and ProfileStatus <> 5)
IF @UserId is not null
BEGIN
SET @UniqueId = NEWID()
INSERT INTO [Reset].[PasswordReset]
(UserId, UniqueId,
DateRequested, DateCompleted)
VALUES
(@UserId, @UniqueId, SYSDATETIME(), NULL)
END
If the user exists I will return the userId (bigint) and the uniqueId (UniqueIdentifier)
when I get to the following line in my C# project
sqlCon.Execute("RequestPasswordReset", p, commandType: CommandType.StoredProcedure);
I get the error message written as the title of this question, can someone explain to me what I'm doing wrong here?
The table structure is as follows:
CREATE TABLE [Reset].[PasswordReset](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[UserId] [bigint] NOT NULL,
[UniqueId] [uniqueidentifier] NOT NULL,
[DateRequested] [datetime] NOT NULL,
[DateCompleted] [datetime] NULL,
CONSTRAINT [PK_Reset]].[PasswordReset] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
User Profile table as requested
CREATE TABLE [User].[User_Profile](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[UniqueId] [uniqueidentifier] NOT NULL,
[Username] [varchar](25) NOT NULL,
[EmailAddress] [varchar](320) NOT NULL,
[Password] [varchar](200) NOT NULL,
[ProfileStatus] [int] NOT NULL,
CONSTRAINT [PK_User.User_Profile] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]