Beispiel #1
0
        /// <summary>
        /// Removes the column with the specified name from the collection.
        /// </summary>
        public void Remove(string name)
        {
            DataColumn?dc = this[name];

            if (dc == null)
            {
                throw ExceptionBuilder.ColumnNotInTheTable(name, _table.TableName);
            }
            Remove(dc);
        }
        public void Remove(string name)
        {
            DataColumn column = this[name];

            if (column == null)
            {
                throw ExceptionBuilder.ColumnNotInTheTable(name, this.table.TableName);
            }
            this.Remove(column);
        }
Beispiel #3
0
        internal DataColumn GetDataColumn(string columnName)
        {
            DataColumn column = this._columns[columnName];

            if (column == null)
            {
                throw ExceptionBuilder.ColumnNotInTheTable(columnName, this._table.TableName);
            }
            return(column);
        }
Beispiel #4
0
        /// <include file='doc\DataRow.uex' path='docs/doc[@for="DataRow.GetColumnError1"]/*' />
        /// <devdoc>
        ///    <para>Gets the error description for a column, specified by name.</para>
        /// </devdoc>
        public string GetColumnError(string columnName)
        {
            DataColumn column = Table.Columns[columnName];

            if (column == null)
            {
                throw ExceptionBuilder.ColumnNotInTheTable(columnName, Table.TableName);
            }

            return(GetColumnError(column));
        }
Beispiel #5
0
        /// <include file='doc\DataRow.uex' path='docs/doc[@for="DataRow.SetColumnError1"]/*' />
        /// <devdoc>
        ///    <para>Sets
        ///       the error description for a column specified by name.</para>
        /// </devdoc>
        public void SetColumnError(string columnName, string error)
        {
            DataColumn column = Table.Columns[columnName];

            if (column == null)
            {
                throw ExceptionBuilder.ColumnNotInTheTable(columnName, Table.TableName);
            }

            SetColumnError(column, error);
        }
Beispiel #6
0
        /// <include file='doc\DataRow.uex' path='docs/doc[@for="DataRow.this4"]/*' />
        /// <devdoc>
        ///    <para> Gets the specified version of data stored in
        ///       the named column.</para>
        /// </devdoc>
        public object this[string columnName, DataRowVersion version] {
            get {
                DataColumn column = Table.Columns[columnName];
                if (column == null)
                {
                    throw ExceptionBuilder.ColumnNotInTheTable(columnName, Table.TableName);
                }

                return(this[column, version]);
            }
        }
Beispiel #7
0
        // TODO: waiting for COM+ internal fix.
        /// <include file='doc\DataRow.uex' path='docs/doc[@for="DataRow.IsNull1"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Gets a value indicating whether the named column contains a null value.
        ///    </para>
        /// </devdoc>
        public bool IsNull(string columnName)
        {
            DataColumn column = Table.Columns[columnName];

            if (column == null)
            {
                throw ExceptionBuilder.ColumnNotInTheTable(columnName, Table.TableName);
            }

            return(IsNull(column));
        }
Beispiel #8
0
 private void CheckColumn(DataColumn column)
 {
     if (column == null)
     {
         throw ExceptionBuilder.ArgumentNull("column");
     }
     if (column.Table != this._table)
     {
         throw ExceptionBuilder.ColumnNotInTheTable(column.ColumnName, this._table.TableName);
     }
 }
        public override int GetOrdinal(string name)
        {
            this.ValidateOpen("GetOrdinal");
            this.ValidateReader();
            DataColumn column = this.currentDataTable.Columns[name];

            if (column == null)
            {
                throw ExceptionBuilder.ColumnNotInTheTable(name, this.currentDataTable.TableName);
            }
            return(column.Ordinal);
        }
Beispiel #10
0
        public override int GetOrdinal(string name)
        {
            ValidateOpen(nameof(GetOrdinal));
            ValidateReader();
            DataColumn dc = _currentDataTable.Columns[name];

            if (dc != null)
            {
                return(dc.Ordinal);
            }
            else
            {
                throw ExceptionBuilder.ColumnNotInTheTable(name, _currentDataTable.TableName);
            }
        }
Beispiel #11
0
        override public Int32 GetOrdinal(string name)
        {
            ValidateOpen("GetOrdinal");
            ValidateReader();
            DataColumn dc = currentDataTable.Columns[name];

            if (dc != null)
            {
                return(dc.Ordinal);// WebData 113248
            }
            else
            {
                throw ExceptionBuilder.ColumnNotInTheTable(name, currentDataTable.TableName);
            }
        }
Beispiel #12
0
        /// <include file='doc\DataRow.uex' path='docs/doc[@for="DataRow.this1"]/*' />
        /// <devdoc>
        ///    <para>Gets or sets the data stored in the column specified by
        ///       name.</para>
        /// </devdoc>
        public object this[string columnName] {
            get {
                DataColumn column = Table.Columns[columnName];
                if (column == null)
                {
                    throw ExceptionBuilder.ColumnNotInTheTable(columnName, Table.TableName);
                }

                return(this[column]);
            }
            set {
                DataColumn column = Table.Columns[columnName];
                if (column == null)
                {
                    throw ExceptionBuilder.ColumnNotInTheTable(columnName, Table.TableName);
                }

                this[column] = value;
            }
        }
Beispiel #13
0
 public object this[DataColumn column]
 {
     get
     {
         this.CheckColumn(column);
         int defaultRecord = this.GetDefaultRecord();
         return(column[defaultRecord]);
     }
     set
     {
         this.CheckColumn(column);
         if (this.inChangingEvent)
         {
             throw ExceptionBuilder.EditInRowChanging();
         }
         if ((-1L != this.rowID) && column.ReadOnly)
         {
             throw ExceptionBuilder.ReadOnly(column.ColumnName);
         }
         DataColumnChangeEventArgs e = null;
         if (this._table.NeedColumnChangeEvents)
         {
             e = new DataColumnChangeEventArgs(this, column, value);
             this._table.OnColumnChanging(e);
         }
         if (column.Table != this._table)
         {
             throw ExceptionBuilder.ColumnNotInTheTable(column.ColumnName, this._table.TableName);
         }
         if ((-1L != this.rowID) && column.ReadOnly)
         {
             throw ExceptionBuilder.ReadOnly(column.ColumnName);
         }
         object obj2 = (e != null) ? e.ProposedValue : value;
         if (obj2 == null)
         {
             if (column.IsValueType)
             {
                 throw ExceptionBuilder.CannotSetToNull(column);
             }
             obj2 = DBNull.Value;
         }
         bool flag = this.BeginEditInternal();
         try
         {
             int proposedRecordNo = this.GetProposedRecordNo();
             column[proposedRecordNo] = obj2;
         }
         catch (Exception exception)
         {
             if (ADP.IsCatchableOrSecurityExceptionType(exception) && flag)
             {
                 this.CancelEdit();
             }
             throw;
         }
         this.LastChangedColumn = column;
         if (e != null)
         {
             this._table.OnColumnChanged(e);
         }
         if (flag)
         {
             this.EndEdit();
         }
     }
 }