DataTable.HasErrors Özellik
Tanım
public:
property bool HasErrors { bool get(); };
public bool HasErrors { get; }
[System.ComponentModel.Browsable(false)]
public bool HasErrors { get; }
[System.ComponentModel.Browsable(false)]
[System.Data.DataSysDescription("DataTableHasErrorsDescr")]
public bool HasErrors { get; }
member this.HasErrors : bool
[<System.ComponentModel.Browsable(false)>]
member this.HasErrors : bool
[<System.ComponentModel.Browsable(false)>]
[<System.Data.DataSysDescription("DataTableHasErrorsDescr")>]
member this.HasErrors : bool
Public ReadOnly Property HasErrors As Boolean
Özellik Değeri
true
Eğer hata varsa; Aksi takdirde false
.true
if errors exist; otherwise false
.
- Öznitelikler
Örnekler
Aşağıdaki örnek, HasErrors bir tabloda hata olup olmadığını denetlemek için özelliğini kullanır.The following example uses the HasErrors property to check if a table contains errors.
private void CheckForErrors(DataSet dataSet)
{
// Invoke GetChanges on the DataSet to create a reduced set.
DataSet thisDataSet = dataSet.GetChanges();
// Check each table's HasErrors property.
foreach(DataTable table in thisDataSet.Tables)
{
// If HasErrors is true, reconcile errors.
if(table.HasErrors)
{
// Insert code to reconcile errors.
}
}
}
Private Sub CheckForErrors(dataSet As DataSet)
' Invoke GetChanges on the DataSet to create a reduced set.
Dim thisDataSet As DataSet = dataSet.GetChanges()
' Check each table's HasErrors property.
Dim table As DataTable
For Each table In thisDataSet.Tables
' If HasErrors is true, reconcile errors.
If table.HasErrors Then
' Insert code to reconcile errors.
End If
Next table
End Sub
Açıklamalar
Kullanıcılar, içinde bulunan bir veri kümesi üzerinde çalışırken DataTable , değişiklik bazı doğrulama hatalarına neden olursa her değişikliği bir hata ile işaretleyebilirsiniz.As users work on a set of data contained in a DataTable, you can mark each change with an error if the change causes some validation failure. DataRowÖzelliğini kullanarak bir hata iletisiyle tümünü işaretleyebilirsiniz RowError .You can mark an entire DataRow with an error message using the RowError property. Ayrıca, yöntemi ile satır her sütununda hata da ayarlayabilirsiniz SetColumnError .You can also set errors on each column of the row with the SetColumnError method.
Bir veri kaynağını ile güncelleştirmeden önce DataSet , öncelikle GetChanges hedef üzerinde yöntemi çağırmanız önerilir DataSet .Before updating a data source with a DataSet, it's recommended that you first invoke the GetChanges method on the target DataSet. Yöntemi, DataSet yalnızca orijinalde yapılan değişiklikleri içeren bir ile sonuçlanır.The method results in a DataSet that contains only the changes made to the original. DataSet' Yi güncelleştirmek üzere veri kaynağına göndermeden önce, HasErrors satırlardaki satırlara veya sütunlara herhangi bir hata iliştirilmişse, her tablonun özelliğini denetleyin.Before sending the DataSet to the data source for updating, check the HasErrors property of each table to see if any errors have been attached to the rows or columns in the rows.
Her bir hatayı mutabık olduktan sonra, içindeki yöntemiyle ilgili hataları temizleyin ClearErrors DataRow
.After reconciling each error, clear the errors with the ClearErrors method of the DataRow
.