System.Data.DataRow.SetColumnError C# (CSharp) Method

SetColumnError() public method

Sets the error description for a column specified as a .
public SetColumnError ( DataColumn column, string error ) : void
column DataColumn
error string
return void
        public void SetColumnError(DataColumn column, string error)
        {
            CheckColumn(column);

            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataRow.SetColumnError|API> {0}, column={1}, error='{2}'", _objectID, column.ObjectID, error);
            try
            {
                if (_error == null) _error = new DataError();
                if (GetColumnError(column) != error)
                {
                    _error.SetColumnError(column, error);
                    RowErrorChanged();
                }
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }

Same methods

DataRow::SetColumnError ( int columnIndex, string error ) : void
DataRow::SetColumnError ( string columnName, string error ) : void

Usage Example

Example #1
0
        internal override bool IsConstraintViolated()
        {
            if (Index == null)
            {
                Index = Table.GetIndex(Columns, null, DataViewRowState.None, null, false);
            }

            if (Index.HasDuplicates)
            {
                int[] dups = Index.Duplicates;
                for (int i = 0; i < dups.Length; i++)
                {
                    DataRow   row     = Table.RecordCache[dups[i]];
                    ArrayList columns = new ArrayList();
                    ArrayList values  = new ArrayList();
                    foreach (DataColumn col in Columns)
                    {
                        columns.Add(col.ColumnName);
                        values.Add(row[col].ToString());
                    }

                    string columnNames  = String.Join(", ", (string[])columns.ToArray(typeof(string)));
                    string columnValues = String.Join(", ", (string[])values.ToArray(typeof(string)));

                    row.RowError = String.Format("Column '{0}' is constrained to be unique.  Value '{1}' is already present.", columnNames, columnValues);
                    for (int j = 0; j < Columns.Length; ++j)
                    {
                        row.SetColumnError(Columns [j], row.RowError);
                    }
                }
                return(true);
            }
            return(false);
        }
All Usage Examples Of System.Data.DataRow::SetColumnError