> protected Boolean ProcessDataTable(SqlCommand toSqlCommand) > { > Boolean results = false; > > try > { > this.table = new DataTable(); > this.adapter = new SqlDataAdapter(toSqlCommand); > this.adapter.SelectCommand = toSqlCommand; > this.adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; // Generate PK information > this.adapter.Fill(this.table); > this.adapter.RowUpdating += new SqlRowUpdatingEventHandler(OnRowUpdating); > > results = true; > } > catch (Exception ex) > { > results = false; > Logging.LogFormat(2, ex.Message); // at least log the problem > } > > return results; > } > // handler for RowUpdating event > private static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e) > { > PrintEventArgs(e); > } > > private static void PrintEventArgs(SqlRowUpdatingEventArgs args) > { > Console.WriteLine("OnRowUpdating"); > Console.WriteLine(" event args: (" + > " command=" + args.Command + > " commandType=" + args.StatementType + > " status=" + args.Status + ")"); > } > /// <summary> > /// Update information > /// </summary> > /// <returns></returns> > public Boolean UpdateRows(Boolean generateCommands = false) > { > Boolean results = false; > try > { > if (generateCommands) > { > > this.adapter.UpdateBatchSize = 1; //Disable batch processing > SqlCommandBuilder builder = new SqlCommandBuilder(adapter); > builder.ConflictOption = ConflictOption.OverwriteChanges; > builder.SetAllValues = false; // Set only changed values > adapter.UpdateCommand = builder.GetUpdateCommand(true); > } > adapter.Update(this.table); > results = true; > } > > catch (Exception ex) > { > results = false; > Logging.LogFormat(2, ex.Message); // at least log the problem > } > > return results; > }>