DataTable.GetChanges Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene una copia dell'oggetto DataTable contenente tutte le modifiche apportate dopo l'ultimo caricamento o dopo AcceptChanges() la chiamata.
Overload
| Nome | Descrizione |
|---|---|
| GetChanges() |
Ottiene una copia dell'oggetto DataTable che contiene tutte le modifiche apportate dopo il caricamento o AcceptChanges() l'ultima chiamata. |
| GetChanges(DataRowState) |
Ottiene una copia dell'oggetto DataTable contenente tutte le modifiche apportate dall'ultimo caricamento o dalla AcceptChanges() chiamata, filtrata in base DataRowStatea . |
GetChanges()
Ottiene una copia dell'oggetto DataTable che contiene tutte le modifiche apportate dopo il caricamento o AcceptChanges() l'ultima chiamata.
public:
System::Data::DataTable ^ GetChanges();
public System.Data.DataTable GetChanges();
member this.GetChanges : unit -> System.Data.DataTable
Public Function GetChanges () As DataTable
Valori restituiti
Copia delle modifiche da questo DataTableoggetto o null se non vengono trovate modifiche.
Esempio
private void UpdateDataTable(DataTable table,
OleDbDataAdapter myDataAdapter)
{
DataTable xDataTable = table.GetChanges();
// Check the DataTable for errors.
if (xDataTable.HasErrors)
{
// Insert code to resolve errors.
}
// After fixing errors, update the database with the DataAdapter
myDataAdapter.Update(xDataTable);
}
Private Sub UpdateDataTable(table As DataTable, _
myDataAdapter As OleDbDataAdapter)
Dim xDataTable As DataTable = table.GetChanges()
' Check the DataTable for errors.
If xDataTable.HasErrors Then
' Insert code to resolve errors.
End If
' After fixing errors, update the database with the DataAdapter
myDataAdapter.Update(xDataTable)
End Sub
Commenti
Crea un nuovo oggetto DataSet contenente una copia di tutte le righe nell'originale DataSet con modifiche in sospeso. I vincoli di relazione possono causare l'aggiunta di righe non modificate aggiuntive al nuovo DataSet se le righe non modificate contengono chiavi primarie corrispondenti alle chiavi esterne nelle righe modificate. Il metodo restituisce null (Nothing in Visual Basic) se non sono presenti righe nel DataSet originale con modifiche in sospeso.
Vedi anche
Si applica a
GetChanges(DataRowState)
Ottiene una copia dell'oggetto DataTable contenente tutte le modifiche apportate dall'ultimo caricamento o dalla AcceptChanges() chiamata, filtrata in base DataRowStatea .
public:
System::Data::DataTable ^ GetChanges(System::Data::DataRowState rowStates);
public System.Data.DataTable GetChanges(System.Data.DataRowState rowStates);
member this.GetChanges : System.Data.DataRowState -> System.Data.DataTable
Public Function GetChanges (rowStates As DataRowState) As DataTable
Parametri
- rowStates
- DataRowState
Uno dei DataRowState valori.
Valori restituiti
Copia filtrata dell'oggetto DataTable che può avere azioni eseguite su di esso e successivamente essere unito di nuovo nell'oggetto DataTable utilizzando Merge(DataSet). Se non vengono trovate righe del desiderato DataRowState , il metodo restituisce null.
Esempio
private void ProcessDeletes(DataTable table,
OleDbDataAdapter adapter)
{
DataTable changeTable = table.GetChanges(DataRowState.Deleted);
// Check the DataTable for errors.
if (changeTable.HasErrors)
{
// Insert code to resolve errors.
}
// After fixing errors, update the database with the DataAdapter
adapter.Update(changeTable);
}
Private Sub ProcessDeletes(table As DataTable, _
adapter As OleDbDataAdapter)
Dim changeTable As DataTable = table.GetChanges(DataRowState.Deleted)
' Check the DataTable for errors.
If table.HasErrors Then
' Insert code to resolve errors.
End If
' After fixing errors, update the database with the DataAdapter
adapter.Update(changeTable)
End Sub
Commenti
Il GetChanges metodo viene utilizzato per produrre un secondo DataTable oggetto che contiene solo le modifiche introdotte nell'originale. Utilizzare l'argomento rowStates per specificare il tipo di modifiche che il nuovo oggetto deve includere.
I vincoli di relazione possono causare l'inserimento di righe padre invariate.