| CelEnzo CDC |
System.Data.VersionNotFoundException
Gentili Signori Salve Ho collegato un DataGrid (dg) ad un DataView (dvDettaglioSchede). L’operatore inserisce i dati direttamente nel dg e su un pulsante di conferma io salvo i dati nel database. Richiamando i dati, l’operatore può modificare i prodotti già salvati o aggiungere dei nuovi. Quando processo il tutto: Dim r As dsGenerale.DettaglioSchedeRow Dim rv As DataRowView For Each rv In Me.dvDettaglioSchede r = rv.Row If r.RowState <> DataRowState.Unchanged Then Dim qc As Double = 0 If r.RowState = DataRowState.Added Then qc = r.QuantitàCaricata 'r("QuantitàCaricata", DataRowVersion.Current) If qc = 0 Then r.Delete() End If Else qc = r("QuantitàCaricata", DataRowVersion.Current) - r("QuantitàCaricata", DataRowVersion.Original) End If .-.-.-.-.-.--.-.-. With r rDeBo.QuantitàScaricata += .QuantitàCaricata rDeBo.Prezzo += .Prezzo * .QuantitàCaricata Dim rMag As dsGenerale.ProdottiClientiRow (1)rMag =Me.dsC.ProdottiClienti.FindByIdProdottoCliente(.IdProdottoCliente) (2) rMag.QuantitàStoccata -= qc '.QuantitàCaricata End With dsC è un’istanza di dsGenerale al punto (1) rMag non è Nothing, rMag.QuantitàStoccata è un valore double ed io lo leggo correttamente nel debag come leggo correttamente sia qc oppure r.QuantitàCaricata, al punto(2)malgrado tutti i tentativi che faccio, con un merge con un ds temporaneo, con una variabile, con un salto triplo all’indietro… ma il risultato non cambia; ottengo sempre System.Data.VersionNotFoundException: Nessun dato originale a cui accedere at System.Data.DataTable.SetNewRecord(DataRow, int32 proposedRecord, DataRowAction action, Boolean isInMerge) Oltre a piangere, posso fare qualcos'altro? Grazie per il tempo dedicatomi. Saluti CelEnzo |
| Lorenzo Moretti |
Re: System.Data.VersionNotFoundException
http://msdn.microsoft.com/en-us/library/system.data.versionnotfoundexception.aspx
VersionNotFoundException: "Represents the exception that is thrown when you try to return a version of a DataRow that has been deleted." ....avevi già visto questo? può essere che cerchi di accedere ad un dato di una riga che hai precedentemente cancellato? |
| CelEnzo CDC |
Re: System.Data.VersionNotFoundException
Le righe non erano cancellate.
In qualche maniera ho risolto. ho salvato il dataset con il suo oledataadapter che ha modificato lo stato delle righe e poi ho aggiornato le variabili delle righe sottostanti Grazie a tutti CelEnzo |