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

Merge() public method

public Merge ( DataTable table, bool preserveChanges, MissingSchemaAction missingSchemaAction ) : void
table DataTable
preserveChanges bool
missingSchemaAction MissingSchemaAction
return void
        public void Merge(DataTable table, bool preserveChanges, MissingSchemaAction missingSchemaAction)
        {
            long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Merge|API> {0}, table={1}, preserveChanges={2}, missingSchemaAction={3}", ObjectID, (table != null) ? table.ObjectID : 0, preserveChanges, missingSchemaAction);
            try
            {
                if (table == null)
                {
                    throw ExceptionBuilder.ArgumentNull(nameof(table));
                }

                switch (missingSchemaAction)
                {
                    case MissingSchemaAction.Add:
                    case MissingSchemaAction.Ignore:
                    case MissingSchemaAction.Error:
                    case MissingSchemaAction.AddWithKey:
                        Merger merger = new Merger(this, preserveChanges, missingSchemaAction);
                        merger.MergeTable(table);
                        break;
                    default:
                        throw ADP.InvalidMissingSchemaAction(missingSchemaAction);
                }
            }
            finally
            {
                DataCommonEventSource.Log.ExitScope(logScopeId);
            }
        }

Same methods

DataTable::Merge ( DataTable table ) : void
DataTable::Merge ( DataTable table, bool preserveChanges ) : void

Usage Example

Example #1
0
        public void FormatDataGridView()
        {
            DataTable dt = new DataTable();


            dt = NewDataTable(applicationFileName, ",", true);
            if (applicationFileName.Contains("OPS"))
            {
                dataGridView2.DataSource = dt.Copy();
                dtAll.Merge(dt);
            }
            else if (applicationFileName.Contains("DPM"))
            {
                dataGridView1.DataSource = dt.Copy();
                dtAll.Merge(dt);
            }
            else if (applicationFileName.Contains("BDW"))
            {
                dataGridView3.DataSource = dt.Copy();
                dtAll.Merge(dt);
            }
            else if (applicationFileName.Contains("DEALS"))
            {
                dataGridView4.DataSource = dt.Copy();
                dtAll.Merge(dt);
            }
        }
All Usage Examples Of System.Data.DataTable::Merge
DataTable