I am working with Entity Framework in C# and am having an issue which I have tracked down to the SQL statement being generated.
The stored procedure takes in a table-valued parameter, but this doesn't seem to be the issue.
In SQL Profiler, I am seeing the following being executed:
declare @p3 dbo.PositiveTypes
insert into @p3 values(N'1')
insert into @p3 values(N'4')
insert into @p3 values(N'6')
exec sp_executesql N'dbo.SaveResults',
N'@resultID int, @positiveResults [PositiveTypes] READONLY',
@resultID=1,
@positiveResults=@p3
This results in:
Msg 201, Level 16, State 4, Procedure SaveResults, Line 0
Procedure or function 'SaveResults' expects parameter '@resultID', which was not supplied.
The definition of this procedure is:
ALTER PROCEDURE [dbo].[SaveResults]
@resultID int,
@positiveResults AS dbo.PositiveTypes READONLY
User defined type is:
CREATE TYPE [dbo].[PositiveTypes] AS TABLE(
[TypeID] [tinyint] NULL
)
What is wrong with this sp_executesql syntax? Why does it think that @resultID is not being passed properly here?