Windows 7, Visual Studio 2017, MVC5 app using .Net Framework 4.8:
I'm trying to call a stored proc that accepts a single nvarchar(450) parameter. When I try to call that stored proc from my code, I get this:
Procedure or function 'StoredProcName' expects parameter '@paramName', which was not supplied.
The
SqlParameter
array inside the
SqlCommand
object does indeed contain a single parameter with the correct name, with the expected value, and of the expected
SqlDbType
at the time I call
ExecuteQuery
. I examined the above with the debugger, and in an immediate console.
The stored proc does indeed have a single parameter defined like so:
@paramName NVARCHAR(450)
When I execute the stored proc in SSMS, it works as expected.
What I have tried:
I tried the things described in the question. I present the following observed facts:
In the app:
- The SqlCommand.Parameters object contains a single parameter (as intended)
- The parameter is of the correct type (nvarchar)
- The parameter has the correct name ("@paramName")
- The parameter has the expected string value
- The connection to the database succeeds
- The stored proc was found in the database
In the database:
- The stored proc has a single parameter, of type nvarchar
- The stored proc works when I execute it in SSMS with the same parameter value used in the app