UpdateEntitiesDirectly - Stumped

Posts   
 
    
lotek
User
Posts: 56
Joined: 14-Sep-2005
# Posted on: 28-Feb-2006 03:32:23   

Im stumpted on this one...

I have a table like this....

id identity(1,1), field1 char(10) PK field2 int PK

I need to update field1 using the id field. (I dont know the value of field2)

Entity entity = new Entity(); entity.field1 = "Something"; IRelationPredicateBucket filter = new RelationPredicateBucket(); filter.PredicateExpression.Add(PredicateFactory.CompareValue(EntityFieldIndex.id, ComparisonOperator.Equal, 1)); adapter.UpdateEntitiesDirectly(entity, filter);

Whats wrong with this? Im not getting and error or an update...

Thanks Matt

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 28-Feb-2006 04:28:34   

is there any data with an ID of 1 in your table?

lotek
User
Posts: 56
Joined: 14-Sep-2005
# Posted on: 28-Feb-2006 04:32:28   

No just one row with an id of 2....

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 28-Feb-2006 06:57:53   

Exactly, you are updating using (WHERE ID = 1) And there is no row having the ID = 1.

So there is no row getting updated.

lotek
User
Posts: 56
Joined: 14-Sep-2005
# Posted on: 28-Feb-2006 17:24:15   

Hehe sorry, but i was just using the "1" as an example. I traced the value and ID = 2. So im still stumped why this isnt working.

-Matt

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 01-Mar-2006 03:02:50   

I don't believe you can update a field that is part of a primary key. What is the error that you are receiving.

lotek
User
Posts: 56
Joined: 14-Sep-2005
# Posted on: 01-Mar-2006 18:33:42   

Im not recieving any error. Just nothing happens... I dont see why you can't update a field that is part of a primary key? It seems like this is common practice no?

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 02-Mar-2006 02:29:18   

Take a look at this thread and see if implementing the solution in the last post helps. http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=630