3

I have an EF 5 app and I'm trying to call a stored procedure which takes a single parameter, as follows:

enter image description here

As you can see, I am supplying a parameter, and it's the correct name. Can anyone tell me where I'm going wrong? The image may be a bit hard to see. The error says:

"Procedure or function 'AddRowToPanelCdClAllData' expects parameter '@SubId' which was not supplied."

The line of code generating the error is as follows:

  internal void AddRowToPanelCdClAllData(string subId) 
    {
        this.Database.Database.ExecuteSqlCommand("AddRowToPanelCdClAllData", new SqlParameter("@SubId", subId));
    }

The value of 'subId' contains a value and is not null.

7
  • can you post the code line and the error as text instead of an image? it's impossible to read what that image says Commented Aug 6, 2013 at 20:06
  • This often occurs when the parameter you specify has a NULL value but the stored procedure parameter does not accept NULLs. Can you double check that subId does have a value? Commented Aug 6, 2013 at 20:06
  • @AndrewCounts i.sstatic.net/DzHyf.png Commented Aug 6, 2013 at 20:06
  • Have you checked if subId is null or not? Commented Aug 6, 2013 at 20:06
  • @AndrewCounts - Thank you. I modified my post. Commented Aug 6, 2013 at 20:08

1 Answer 1

8

try this:

this.Database.Database.ExecuteSqlCommand("AddRowToPanelCdClAllData @SubId",
                                          new SqlParameter("SubId", subId));
Sign up to request clarification or add additional context in comments.

2 Comments

I can't believe it, but that works. I never would have thought to try that.
What about multiple parameters?

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.