Print Page | Close Window

Unable to bind a grid.

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=121
Printed Date: 07-Nov-2025 at 2:56pm


Topic: Unable to bind a grid.
Posted By: wyattda
Subject: Unable to bind a grid.
Date Posted: 10-Jul-2007 at 2:01pm
I am using the following code:

PersistenceManager manager = PersistenceManager.DefaultManager;

EntityQuery query = new EntityQuery(typeof(Customers), Customers.ActiveEntityColumn, EntityQueryOp.EQ, "True");

EntityList<Customers> customers = manager.GetEntities<Customers>(query);

dataGridViewMain.DataSource = customers;

When it gets to the EntityList<Customers> line of code it throws the following error: "An item with the same key has already been added.".

I have used DevForce before with no problems.  I think the main difference is the database that I am using.  I have no idea about the quality of the data in this database.  Could it be something to do with the data, or am I just using it incorrectly?

Please help..

Thanks,
Wyatt



Replies:
Posted By: davidklitzke
Date Posted: 10-Jul-2007 at 2:42pm
Wyatt,
 
I think that you are completely correct.  Bad data can certainly cause the problem that you are seeing, and I don't see anything wrong or suspicious in your code.
 
David 


Posted By: wyattda
Date Posted: 10-Jul-2007 at 2:46pm
I just noticed that even with a table that has only 2 records it still gives that error.  The table with the 2 records has good data.  So if the data appears to be ok then what else can it be?


Posted By: naveen.menon
Date Posted: 11-Jul-2007 at 1:04pm
Have you checked the OM to see if the the columns that have been set as keys do not have repetitive values in the database?



Print Page | Close Window