Leer en inglés

Compartir a través de


DataSet.HasChanges Método

Definición

Obtiene un valor que indica si DataSet presenta cambios, incluyendo filas nuevas, eliminadas o modificadas.

Sobrecargas

HasChanges()

Obtiene un valor que indica si DataSet presenta cambios, incluyendo filas nuevas, eliminadas o modificadas.

HasChanges(DataRowState)

Obtiene un valor que indica si DataSet presenta cambios, incluidas filas nuevas, eliminadas o modificadas, filtrados por DataRowState.

HasChanges()

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Obtiene un valor que indica si DataSet presenta cambios, incluyendo filas nuevas, eliminadas o modificadas.

public bool HasChanges ();

Devoluciones

true si DataSet presenta cambios; de lo contrario, false.

Ejemplos

En el ejemplo siguiente se usa el GetChanges método para crear un segundo DataSet objeto que se usa para actualizar un origen de datos.

private void UpdateDataSet(DataSet dataSet)
{
    // Check for changes with the HasChanges method first.
    if(!dataSet.HasChanges()) return;

    // Create temporary DataSet variable.
    DataSet tempDataSet;

    // GetChanges for modified rows only.
    tempDataSet = dataSet.GetChanges(DataRowState.Modified);

    // Check the DataSet for errors.
    if(tempDataSet.HasErrors)
    {
        // Insert code to resolve errors.
    }
    // After fixing errors, update the data source with
    // the DataAdapter used to create the DataSet.
    myOleDbDataAdapter.Update(tempDataSet);
}

Consulte también

Se aplica a

.NET 9 y otras versiones
Producto Versiones
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

HasChanges(DataRowState)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Obtiene un valor que indica si DataSet presenta cambios, incluidas filas nuevas, eliminadas o modificadas, filtrados por DataRowState.

public bool HasChanges (System.Data.DataRowState rowStates);

Parámetros

rowStates
DataRowState

Uno de los valores de DataRowState.

Devoluciones

true si DataSet presenta cambios; de lo contrario, false.

Ejemplos

En el ejemplo siguiente se usa el GetChanges método para crear un segundo DataSet objeto, que se usa para actualizar un origen de datos.

private void UpdateDataSet(DataSet dataSet)
{
    // Check for changes with the HasChanges method first.
    if(!dataSet.HasChanges(DataRowState.Modified)) return;

    // Create temporary DataSet variable and
    // GetChanges for modified rows only.
    DataSet tempDataSet =
        dataSet.GetChanges(DataRowState.Modified);

    // Check the DataSet for errors.
    if(tempDataSet.HasErrors)
    {
        // Insert code to resolve errors.
    }
    // After fixing errors, update the data source with
    // the DataAdapter used to create the DataSet.
    adapter.Update(tempDataSet);
}

Comentarios

Examine la HasChanges propiedad de antes de DataSet invocar el GetChanges método .

Consulte también

Se aplica a

.NET 9 y otras versiones
Producto Versiones
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1