none
Error calling Stored Procedure RRS feed

  • Question

  • HI,

    While using entity framework I also want to call some stored procedures, but I get an error. Can anyone help me out?

    First the error:
    System.InvalidOperationException was caught
      Message="The value of EntityCommand.CommandText is not valid for a StoredProcedure command. The EntityCommand.CommandText value must be of the form 'ContainerName.FunctionImportName'."
      Source="System.Data.Entity"

    What do I do:
    I created an edmx en selectet a the stored procedurs I want to call.
    For two I already did a function import and called the one to call "SL_BERICHT_04", return type is none. SP name = SL_AFH_MSG_UIT_VERWERK_BERICHT_04
    Access = public

    My code
    using (EntityConnection conn = new EntityConnection())
                {
                    conn.ConnectionString = ConfigurationManager.ConnectionStrings["SLadapter_con"].ToString();
                    conn.Open();
                    EntityCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "SL_BERICHT_04";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("P_RELATIE_ID", relId);
    
                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception e)
    This generates the error as above.
    What is wrong????

    Robin
    Tuesday, July 7, 2009 11:30 AM

Answers

  • Problem solved.
    cmd.CommandText = "SL_BERICHT_04"; had to be cmd.CommandText = "SLadapter_con.SL_BERICHT_04";

    Robin
    Tuesday, July 7, 2009 12:31 PM