Randy Minder
Randy Minder

Reputation: 48412

Entity Framework 5 - Calling a stored procedure with parameters. Parameter not recognized

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.

Upvotes: 3

Views: 6525

Answers (1)

Claies
Claies

Reputation: 22323

try this:

this.Database.Database.ExecuteSqlCommand("AddRowToPanelCdClAllData @SubId",
                                          new SqlParameter("SubId", subId));

Upvotes: 8

Related Questions