views:

250

answers:

2

Hi guys, during an update command I was received the following error: Operation is not valid due to the current state of the object

I had tried to remove one column from the update command and it works fine. This column is a FK that is similar to the other FK that works fine.

Any idea? tnx

this is the code that execute the update:

                ti.NumeroTitolo = titolo.Numero;
                ti.RKTipoTitoloGenereTitolo = titolo.RkTipoTitoloGenereTitolo;
                ti.RKBanca = titolo.RkBanca;
                ti.DataScadenza = titolo.DataScadenza;
                ti.RKTipoEsito = titolo.RkTipoEsito; 
                ti.ImportoTitolo = titolo.ImportoTitolo;

                _dc.SubmitChanges();
A: 

The problem may be caused by a relationship or other constraint. For example if you are attempting to drop a row who's Id is referenced by some other table with a relationship. Perhaps if you post the SQL or LINQ query that is giving the error we can help you more.

grenade
I had added the code
Salvatore Di Fazio
+2  A: 

Hey,

Check this out: http://social.msdn.microsoft.com/forums/en-US/linqtosql/thread/f9c4a01a-195a-4f2b-a1cb-e2fa06e28b25/

Brian
+1 thats what I was about to post. Cheers~
Ben Ziegler