System.Data.DataTable.Clear C# (CSharp) Method

Clear() private method

private Clear ( bool clearAll ) : void
clearAll bool
return void
        internal void Clear(bool clearAll)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Clear|INFO> {0}, clearAll={1}", ObjectID, clearAll);
            try
            {
                Debug.Assert(null == _rowDiffId, "wasn't previously cleared");
                _rowDiffId = null;

                if (_dataSet != null)
                    _dataSet.OnClearFunctionCalled(this);
                bool shouldFireClearEvents = (Rows.Count != 0); // if Rows is already empty, this is noop

                DataTableClearEventArgs e = null;
                if (shouldFireClearEvents)
                {
                    e = new DataTableClearEventArgs(this);
                    OnTableClearing(e);
                }

                if (_dataSet != null && _dataSet.EnforceConstraints)
                {
                    for (ParentForeignKeyConstraintEnumerator constraints = new ParentForeignKeyConstraintEnumerator(_dataSet, this); constraints.GetNext();)
                    {
                        ForeignKeyConstraint constraint = constraints.GetForeignKeyConstraint();
                        constraint.CheckCanClearParentTable(this);
                    }
                }

                _recordManager.Clear(clearAll);

                // this improves performance by iterating over rows instead of computing by index
                foreach (DataRow row in Rows)
                {
                    row._oldRecord = -1;
                    row._newRecord = -1;
                    row._tempRecord = -1;
                    row.rowID = -1;
                    row.RBTreeNodeId = 0;
                }
                Rows.ArrayClear();

                ResetIndexes();

                if (shouldFireClearEvents)
                {
                    OnTableCleared(e);
                }

                foreach (DataColumn column in Columns)
                {
                    EvaluateDependentExpressions(column);
                }
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }

Same methods

DataTable::Clear ( ) : void

Usage Example

コード例 #1
1
ファイル: Ponuda.cs プロジェクト: vodolijabg/LS
        public void DajPonudu(DataTable ponuda, Int32 ponuda_ID)
        {
            SqlConnection _konekcijaSqlConnection = new SqlConnection();
            using (_konekcijaSqlConnection = Konekcija.DajKonekciju())
            {
                SqlDataAdapter _dajPonuduSQLDataAdapter = new SqlDataAdapter();
                SqlCommand _dajPoslednjuPonuduSqlCommand = new SqlCommand("SELECT  * FROM  vwPonudaZaglavlje where Ponuda_ID = " + ponuda_ID, _konekcijaSqlConnection);

                _dajPonuduSQLDataAdapter.SelectCommand = _dajPoslednjuPonuduSqlCommand;

                //isprazni tabelu
                ponuda.Clear();

                try
                {
                    //napuni tabelu 
                    _dajPonuduSQLDataAdapter.Fill(ponuda);
                }
                catch (Exception)
                {
                    throw;
                }
            }

        }
All Usage Examples Of System.Data.DataTable::Clear
DataTable