0

I have written this stored procedure that accepts the clientId as parameter. As you can see in the SQL Server trace, I have passed the client id while calling from .NET, but still its showing the error that clientId parameter is not supplied. What am I doing wrong ?

Stored procedure:

enter image description here

SQL Server trace when calling from .NET:

enter image description here

I'm still getting the error:

Procedure or function 'USP_LoadPerformaceTemplate' expects parameter '@clientId', which was not supplied.

2
  • Does that error show up in your trace? It should - so perhaps you are not looking at the source of the problem. The most likely explanation is a fault in your application code - which you should post. And please avoid using images - something a person with your rep should know. Commented Jun 9, 2021 at 18:04
  • The call to the SP is missing the parameter. The call to sp_executesql passes it, but that statement it runs does nothing with said parameter; it just runs the SQL dbo.USP_LoadPerformaceTemplate. we need the application code here. Commented Jun 9, 2021 at 18:07

1 Answer 1

1

In your C# code (which you haven't shown us), you have not set CommandType

command.CommandType = CommandType.StoredProcedure;
// or
using (var command = new ... { CommandType = CommandType.StoredProcedure})

So what is happening is that the SQL is being interpreted as a direct query batch:

[dbo].[USP_LoadPerformaceTemplate]

The word EXEC is not needed. So it is trying to execute it without the parameter.

But when CommandType.StoredProcedure is specified, it is sent as an RPC command to call the stored procedure.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.