Hello i cannot wrap my head around why i get the error saying that this SP expects @id which was not given when it is quite clearly given. this is how the code looks
public Task<bool> InsertMessage(Message msg)
{
return CallDatabase(async (connection) =>
{
var affectedows = await connection.ExecuteAsync(
"messages_insert",
new
{
msg.Id,
msg.Group,
msg.GroupUserId,
msg.userId,
msg.StartTime,
msg.FinishTime
},
commandTimeout: 3600,
commandType: CommandType.StoredProcedure
);
return affectedows == 1;
});
}
And here is the SP in the db
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[messages_insert]') AND type in (N'P', N'PC'))
BEGIN
PRINT 'DROP PROCEDURE [dbo].[messages_insert]';
DROP PROCEDURE [dbo].[messages_insert];
END
GO
PRINT 'CREATE PROCEDURE [dbo].[messages_insert]';
GO
CREATE PROCEDURE [dbo].[messages_insert]
@id BIGINT, -
@group INT,
@group_user_id VARCHAR(100),
@user_id VARCHAR(100),
@start_time DATETIME,
@finish_time DATETIME
AS
BEGIN
INSERT INTO messages(id, group, group_user_id, user_id, start_time, finish_time)
VALUES(@id, @group, @group_user_id, @user_id, @start_time, @finish_time);
END
GO
I really cant see were i am going wrong and the stack trace really says nothing
Exception: System.Data.SqlClient.SqlException (0x80131904): Procedure or function 'messages_insert' expects parameter '@id', which was not supplied.
Ensure that msg.Id is not null when calling the stored procedure.
User contributions licensed under CC BY-SA 3.0