ENTITYCOMMANDEXECUTIONEXCEPTION WAS UNHANDLED SEE INNEREXCEPTION FOR DETAILS

E E Cummings

Total Post:26

Points:182
Posted by  E E Cummings
 4082  View(s)
Ratings:
Rate this:
Hi All,

I am trying to connect my C# application with SQL server compact edition using ADO.NET entity Model.

I think I have been successfully able to generate the model against the database schema.

However when I try to use the entity objects in code I get the

EntityCommandExecutionException` was unhandled error along with "An error occurred while executing the command definition. See the inner exception for details."

Here's the code

Database1Entities db = new Database1Entities();
var query = from item in db.People
                    select Name;
foreach (var item in query)
{
    MessageBox.Show("The name of the customer is " + item);
}


It says to check inner exception. When I did checked InnerException gave me the error

"InnerException {"A parameter is not allowed in this location. Ensure that the '@' sign is in a valid location or that parameters are valid at all in this SQL

statement."} System.Exception {System.Data.SqlServerCe.SqlCeException}"

Now I am entirely new to using entity framework for generating objects from database sachems. I would really appreciate some guidance in this regard.

Thanks in advance for any recommendations or solutions.
  1. Dev Patel

    Post:26

    Points:182
    Re: EntityCommandExecutionException was unhandled see innerException for Details

    Hi,


    The problem wasn't with entity framework or connection.

    The problem was with your LINQ query.

    The correct query as following

    var query = from item in db.People
                select item.Name;

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!