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

SetColumnError() public method

Sets the error description for a column specified by index.
public SetColumnError ( int columnIndex, string error ) : void
columnIndex int
error string
return void
        public void SetColumnError(int columnIndex, string error)
        {
            DataColumn column = _columns[columnIndex];
            if (column == null)
            {
                throw ExceptionBuilder.ColumnOutOfRange(columnIndex);
            }
            SetColumnError(column, error);
        }

Same methods

DataRow::SetColumnError ( DataColumn column, 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