Home > DeveloperSection > Forums > EntityCommandExecutionException was unhandled see innerException for Details
E E Cummings
E E Cummings

Total Post:26

Points:182
Posted on    June-19-2013 3:00 AM

 ADO.Net ADO.Net 
Ratings:


 1 Reply(s)
 3174  View(s)
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.


Dev Patel

Total Post:26

Points:182
Posted on    June-19-2013 8:25 AM

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;

Don't want to miss updates? Please click the below button!

Follow MindStick