protected override void OnRowUpdating (RowUpdatingEventArgs value) { throw new NotImplementedException (); }
/// <summary> /// Raised by the underlying DbDataAdapter when a row is being updated /// </summary> /// <param name="value">The event's specifics</param> protected override void OnRowUpdating(RowUpdatingEventArgs value) { EventHandler<RowUpdatingEventArgs> handler = base.Events[_updatingEventPH] as EventHandler<RowUpdatingEventArgs>; if (handler != null) handler(this, value); }
private void RowUpdatingHandler (object sender, RowUpdatingEventArgs args) { if (args.Command != null) return; try { switch (args.StatementType) { case StatementType.Insert: args.Command = GetInsertCommand (); break; case StatementType.Update: args.Command = GetUpdateCommand (); break; case StatementType.Delete: args.Command = GetDeleteCommand (); break; } } catch (Exception e) { args.Errors = e; args.Status = UpdateStatus.ErrorsOccurred; } }
/// <summary> /// Overridden. Raises the RowUpdating event. /// </summary> /// <param name="value">A MySqlRowUpdatingEventArgs that contains the event data.</param> override protected void OnRowUpdating(RowUpdatingEventArgs value) { if (RowUpdating != null) RowUpdating(this, (value as MySqlRowUpdatingEventArgs)); }
protected override void OnRowUpdating(RowUpdatingEventArgs value) { if (this.RowUpdating != null) { this.RowUpdating(this, value as MySqlRowUpdatingEventArgs); } }
protected override void OnRowUpdating(RowUpdatingEventArgs value) { var handler = Events[updatingEventKey] as EventHandler<RowUpdatingEventArgs>; if (handler != null) handler(this, value); }
protected void RowUpdatingHandler(RowUpdatingEventArgs rowUpdatingEvent) { if (rowUpdatingEvent == null) { throw ADP.ArgumentNull("rowUpdatingEvent"); } try { if (rowUpdatingEvent.Status == UpdateStatus.Continue) { StatementType statementType = rowUpdatingEvent.StatementType; DbCommand insertCommand = (DbCommand) rowUpdatingEvent.Command; if (insertCommand != null) { switch (statementType) { case StatementType.Select: return; case StatementType.Insert: insertCommand = this.InsertCommand; break; case StatementType.Update: insertCommand = this.UpdateCommand; break; case StatementType.Delete: insertCommand = this.DeleteCommand; break; default: throw ADP.InvalidStatementType(statementType); } if (insertCommand != rowUpdatingEvent.Command) { insertCommand = (DbCommand) rowUpdatingEvent.Command; if ((insertCommand != null) && (insertCommand.Connection == null)) { DbDataAdapter dataAdapter = this.DataAdapter; DbCommand command2 = (dataAdapter != null) ? dataAdapter.SelectCommand : null; if (command2 != null) { insertCommand.Connection = command2.Connection; } } } else { insertCommand = null; } } if (insertCommand == null) { this.RowUpdatingHandlerBuilder(rowUpdatingEvent); } } } catch (Exception exception) { if (!ADP.IsCatchableExceptionType(exception)) { throw; } ADP.TraceExceptionForCapture(exception); rowUpdatingEvent.Status = UpdateStatus.ErrorsOccurred; rowUpdatingEvent.Errors = exception; } }
protected virtual void OnRowUpdating(RowUpdatingEventArgs value) { }
protected void RowUpdatingHandler (object sender, RowUpdatingEventArgs rowUpdatingEvent) { throw new NotImplementedException (); }
protected override void OnRowUpdating( RowUpdatingEventArgs value) { }
/// <summary> /// Raises the RowUpdating event of a .NET Framework data provider. /// </summary> /// <param name="value"> An <see cref="T:System.Data.Common.RowUpdatingEventArgs" /> that contains the event data. </param> protected override void OnRowUpdating(RowUpdatingEventArgs value) { if (RowUpdating != null) RowUpdating(this, (value as CUBRIDRowUpdatingEventArgs)); }
protected virtual void OnRowUpdating (RowUpdatingEventArgs value) { if (Events ["RowUpdating"] != null) { Delegate [] rowUpdatingList = Events ["RowUpdating"].GetInvocationList (); foreach (Delegate rowUpdating in rowUpdatingList) { MethodInfo rowUpdatingMethod = rowUpdating.Method; rowUpdatingMethod.Invoke (value, null); } } }
protected abstract void OnRowUpdating (RowUpdatingEventArgs value);
/// <summary> /// Raises the RowUpdated event of a Sqlite data provider. /// </summary> /// <param name="args">A RowUpdatedEventArgs that contains the event data.</param> protected override void OnRowUpdating (RowUpdatingEventArgs args) { if (RowUpdating != null) RowUpdating(this, args); }
private void RowUpdatingHandlerBuilder(RowUpdatingEventArgs rowUpdatingEvent) { DbCommand command; DataRow dataRow = rowUpdatingEvent.Row; this.BuildCache(false, dataRow, false); switch (rowUpdatingEvent.StatementType) { case StatementType.Insert: command = this.BuildInsertCommand(rowUpdatingEvent.TableMapping, dataRow); break; case StatementType.Update: command = this.BuildUpdateCommand(rowUpdatingEvent.TableMapping, dataRow); break; case StatementType.Delete: command = this.BuildDeleteCommand(rowUpdatingEvent.TableMapping, dataRow); break; default: throw ADP.InvalidStatementType(rowUpdatingEvent.StatementType); } if (command == null) { if (dataRow != null) { dataRow.AcceptChanges(); } rowUpdatingEvent.Status = UpdateStatus.SkipCurrentRow; } rowUpdatingEvent.Command = command; }
protected virtual int Update(DataRow [] dataRows, DataTableMapping tableMapping) { int updateCount = 0; foreach (DataRow row in dataRows) { StatementType statementType = StatementType.Update; IDbCommand command = null; string commandName = String.Empty; switch (row.RowState) { case DataRowState.Added: statementType = StatementType.Insert; command = ((IDbDataAdapter)this).InsertCommand; commandName = "Insert"; break; case DataRowState.Deleted: statementType = StatementType.Delete; command = ((IDbDataAdapter)this).DeleteCommand; commandName = "Delete"; break; case DataRowState.Modified: statementType = StatementType.Update; command = ((IDbDataAdapter)this).UpdateCommand; commandName = "Update"; break; case DataRowState.Unchanged: case DataRowState.Detached: continue; } RowUpdatingEventArgs argsUpdating = CreateRowUpdatingEvent(row, command, statementType, tableMapping); row.RowError = null; OnRowUpdating(argsUpdating); switch (argsUpdating.Status) { case UpdateStatus.Continue: //continue in update operation break; case UpdateStatus.ErrorsOccurred: if (argsUpdating.Errors == null) { argsUpdating.Errors = ExceptionHelper.RowUpdatedError(); } row.RowError += argsUpdating.Errors.Message; if (!ContinueUpdateOnError) { throw argsUpdating.Errors; } continue; case UpdateStatus.SkipAllRemainingRows: return(updateCount); case UpdateStatus.SkipCurrentRow: updateCount++; continue; default: throw ExceptionHelper.InvalidUpdateStatus(argsUpdating.Status); } command = argsUpdating.Command; try { if (command != null) { DataColumnMappingCollection columnMappings = tableMapping.ColumnMappings; #if ONLY_1_1 IDataParameter nullCheckParam = null; #endif foreach (IDataParameter parameter in command.Parameters) { if ((parameter.Direction & ParameterDirection.Input) == 0) { continue; } DataRowVersion rowVersion = parameter.SourceVersion; // Parameter version is ignored for non-update commands if (statementType == StatementType.Delete) { rowVersion = DataRowVersion.Original; } string dsColumnName = parameter.SourceColumn; #if NET_2_0 if (columnMappings.Contains(dsColumnName)) { dsColumnName = columnMappings [dsColumnName].DataSetColumn; parameter.Value = row [dsColumnName, rowVersion]; } else { parameter.Value = null; } DbParameter nullCheckParam = parameter as DbParameter; #else if (columnMappings.Contains(dsColumnName)) { dsColumnName = columnMappings [dsColumnName].DataSetColumn; } if (dsColumnName == null || dsColumnName.Length == 0) { nullCheckParam = parameter; continue; } parameter.Value = row [dsColumnName, rowVersion]; #endif #if NET_2_0 if (nullCheckParam != null && nullCheckParam.SourceColumnNullMapping) { #else if (nullCheckParam != null) { #endif if (parameter.Value != null && parameter.Value != DBNull.Value) { nullCheckParam.Value = 0; } else { nullCheckParam.Value = 1; } nullCheckParam = null; } } } } catch (Exception e) { argsUpdating.Errors = e; argsUpdating.Status = UpdateStatus.ErrorsOccurred; } IDataReader reader = null; try { if (command == null) { throw ExceptionHelper.UpdateRequiresCommand(commandName); } CommandBehavior commandBehavior = CommandBehavior.Default; if (command.Connection.State == ConnectionState.Closed) { command.Connection.Open(); commandBehavior |= CommandBehavior.CloseConnection; } // use ExecuteReader because we want to use the commandbehavior parameter. // so the connection will be closed if needed. reader = command.ExecuteReader(commandBehavior); // update the current row, if the update command returns any resultset // ignore other than the first record. DataColumnMappingCollection columnMappings = tableMapping.ColumnMappings; if (command.UpdatedRowSource == UpdateRowSource.Both || command.UpdatedRowSource == UpdateRowSource.FirstReturnedRecord) { if (reader.Read()) { DataTable retSchema = reader.GetSchemaTable(); foreach (DataRow dr in retSchema.Rows) { string columnName = dr ["ColumnName"].ToString(); string dstColumnName = columnName; if (columnMappings != null && columnMappings.Contains(columnName)) { dstColumnName = columnMappings [dstColumnName].DataSetColumn; } DataColumn dstColumn = row.Table.Columns [dstColumnName]; if (dstColumn == null || (dstColumn.Expression != null && dstColumn.Expression.Length > 0)) { continue; } // info from : http://www.error-bank.com/microsoft.public.dotnet.framework.windowsforms.databinding/ // [email protected]_Thread.aspx // disable readonly for non-expression columns. bool readOnlyState = dstColumn.ReadOnly; dstColumn.ReadOnly = false; try { row [dstColumnName] = reader [columnName]; } finally { dstColumn.ReadOnly = readOnlyState; } } } } reader.Close(); int tmp = reader.RecordsAffected; // records affected is valid only after closing reader // if the execute does not effect any rows we throw an exception. if (tmp == 0) { throw new DBConcurrencyException("Concurrency violation: the " + commandName + "Command affected 0 records.", null, new DataRow [] { row }); } updateCount += tmp; if (command.UpdatedRowSource == UpdateRowSource.Both || command.UpdatedRowSource == UpdateRowSource.OutputParameters) { // Update output parameters to row values foreach (IDataParameter parameter in command.Parameters) { if (parameter.Direction != ParameterDirection.InputOutput && parameter.Direction != ParameterDirection.Output && parameter.Direction != ParameterDirection.ReturnValue) { continue; } string dsColumnName = parameter.SourceColumn; if (columnMappings != null && columnMappings.Contains(parameter.SourceColumn)) { dsColumnName = columnMappings [parameter.SourceColumn].DataSetColumn; } DataColumn dstColumn = row.Table.Columns [dsColumnName]; if (dstColumn == null || (dstColumn.Expression != null && dstColumn.Expression.Length > 0)) { continue; } bool readOnlyState = dstColumn.ReadOnly; dstColumn.ReadOnly = false; try { row [dsColumnName] = parameter.Value; } finally { dstColumn.ReadOnly = readOnlyState; } } } RowUpdatedEventArgs updatedArgs = CreateRowUpdatedEvent(row, command, statementType, tableMapping); OnRowUpdated(updatedArgs); switch (updatedArgs.Status) { case UpdateStatus.Continue: break; case UpdateStatus.ErrorsOccurred: if (updatedArgs.Errors == null) { updatedArgs.Errors = ExceptionHelper.RowUpdatedError(); } row.RowError += updatedArgs.Errors.Message; if (!ContinueUpdateOnError) { throw updatedArgs.Errors; } break; case UpdateStatus.SkipCurrentRow: continue; case UpdateStatus.SkipAllRemainingRows: return(updateCount); } #if NET_2_0 if (!AcceptChangesDuringUpdate) { continue; } #endif row.AcceptChanges(); } catch (Exception e) { row.RowError = e.Message; if (!ContinueUpdateOnError) { throw e; } } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } } return(updateCount); }
protected void RowUpdatingHandler(RowUpdatingEventArgs rowUpdatingEvent) { if (null == rowUpdatingEvent) { throw ADP.ArgumentNull("rowUpdatingEvent"); } try { if (UpdateStatus.Continue == rowUpdatingEvent.Status) { StatementType stmtType = rowUpdatingEvent.StatementType; DbCommand command = (DbCommand)rowUpdatingEvent.Command; if (null != command) { switch(stmtType) { case StatementType.Select: Debug.Assert(false, "how did we get here?"); return; // don't mess with it case StatementType.Insert: command = InsertCommand; break; case StatementType.Update: command = UpdateCommand; break; case StatementType.Delete: command = DeleteCommand; break; default: throw ADP.InvalidStatementType(stmtType); } if (command != rowUpdatingEvent.Command) { command = (DbCommand)rowUpdatingEvent.Command; if ((null != command) && (null == command.Connection)) { // MDAC 87649 DbDataAdapter adapter = DataAdapter; DbCommand select = ((null != adapter) ? ((DbCommand)adapter.SelectCommand) : null); if (null != select) { command.Connection = (DbConnection)select.Connection; } } // user command, not a command builder command } else command = null; } if (null == command) { RowUpdatingHandlerBuilder(rowUpdatingEvent); } } } catch(Exception e) { // if (!ADP.IsCatchableExceptionType(e)) { throw; } ADP.TraceExceptionForCapture(e); rowUpdatingEvent.Status = UpdateStatus.ErrorsOccurred; rowUpdatingEvent.Errors = e; } }
protected override void OnRowUpdating (RowUpdatingEventArgs value) { SybaseRowUpdatingEventHandler handler = (SybaseRowUpdatingEventHandler) Events[EventRowUpdating]; if ((handler != null) && (value is SybaseRowUpdatingEventArgs)) handler(this, (SybaseRowUpdatingEventArgs) value); }
private void RowUpdatingHandlerBuilder(RowUpdatingEventArgs rowUpdatingEvent) { // MDAC 58710 - unable to tell Update method that Event opened connection and Update needs to close when done // HackFix - the Update method will close the connection if command was null and returned command.Connection is same as SelectCommand.Connection DataRow datarow = rowUpdatingEvent.Row; BuildCache(false, datarow, false); DbCommand command; switch(rowUpdatingEvent.StatementType) { case StatementType.Insert: command = BuildInsertCommand(rowUpdatingEvent.TableMapping, datarow); break; case StatementType.Update: command = BuildUpdateCommand(rowUpdatingEvent.TableMapping, datarow); break; case StatementType.Delete: command = BuildDeleteCommand(rowUpdatingEvent.TableMapping, datarow); break; #if DEBUG case StatementType.Select: Debug.Assert(false, "how did we get here?"); goto default; #endif default: throw ADP.InvalidStatementType(rowUpdatingEvent.StatementType); } if (null == command) { if (null != datarow) { datarow.AcceptChanges(); } rowUpdatingEvent.Status = UpdateStatus.SkipCurrentRow; } rowUpdatingEvent.Command = command; }
protected override void OnRowUpdating(RowUpdatingEventArgs value) { CrmDataAdapterRowUpdatingEventHandler handler = (CrmDataAdapterRowUpdatingEventHandler)Events[EventRowUpdating]; if ((null != handler) && (value is CrmDataAdapterRowUpdatingEventArgs)) { handler(this, (CrmDataAdapterRowUpdatingEventArgs)value); } }
private void OnRowUpdating(Object sender, RowUpdatingEventArgs args) { // make sure we are still to proceed if (args.Status != UpdateStatus.Continue) return; switch( args.StatementType ) { case StatementType.Delete: args.Command = GetDeleteCommand(); break; case StatementType.Update: args.Command = GetUpdateCommand(); break; case StatementType.Insert: args.Command = GetInsertCommand(); break; default: return; } SetParameterValues(args.Command, args.Row); }
override protected void OnRowUpdating(RowUpdatingEventArgs value) { VirtuosoRowUpdatingEventHandler handler = (VirtuosoRowUpdatingEventHandler) Events[EventRowUpdating]; if ((null != handler) && (value is VirtuosoRowUpdatingEventArgs)) { handler(this, (VirtuosoRowUpdatingEventArgs) value); } }
protected override void OnRowUpdating(System.Data.Common.RowUpdatingEventArgs value) { }
private void RowUpdatingEventHandler(object sender, RowUpdatingEventArgs e) { base.RowUpdatingHandler(e); }
virtual protected void OnRowUpdating(RowUpdatingEventArgs value) { // V1.0.3300 }
protected override void OnRowUpdating(RowUpdatingEventArgs value) { OdbcRowUpdatingEventHandler handler = (OdbcRowUpdatingEventHandler) base.Events[EventRowUpdating]; if ((handler != null) && (value is OdbcRowUpdatingEventArgs)) { handler(this, (OdbcRowUpdatingEventArgs) value); } base.OnRowUpdating(value); }
override protected void OnRowUpdating(RowUpdatingEventArgs value) { SqlRowUpdatingEventHandler handler = (SqlRowUpdatingEventHandler) Events[EventRowUpdating]; if ((null != handler) && (value is SqlRowUpdatingEventArgs)) { handler(this, (SqlRowUpdatingEventArgs) value); } base.OnRowUpdating(value); }
protected override void OnRowUpdating(RowUpdatingEventArgs value) { NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "OnRowUpdating"); if ((RowUpdating != null) && (value is NpgsqlRowUpdatingEventArgs)) { RowUpdating(this, (NpgsqlRowUpdatingEventArgs) value); } }
protected override void OnRowUpdating(RowUpdatingEventArgs value) { EventHandler<H2RowUpdatingEventArgs> handler = (EventHandler<H2RowUpdatingEventArgs>)Events[EventRowUpdating]; if (null != handler) { handler(this, (H2RowUpdatingEventArgs)value); } }
protected override void OnRowUpdating(RowUpdatingEventArgs value) { FbRowUpdatingEventHandler handler = null; handler = (FbRowUpdatingEventHandler)base.Events[EventRowUpdating]; if ((null != handler) && (value is FbRowUpdatingEventArgs) && (value != null)) { handler(this, (FbRowUpdatingEventArgs)value); } }
private void UpdatingRowStatusErrors(RowUpdatingEventArgs rowUpdatedEvent, DataRow dataRow) { Debug.Assert(null != dataRow, "null dataRow"); Exception errors = rowUpdatedEvent.Errors; if (null == errors) { // user changed status to ErrorsOccured without supplying an exception message errors = ADP.RowUpdatingErrors(); rowUpdatedEvent.Errors = errors; } string message = errors.Message; dataRow.RowError += message; if (!ContinueUpdateOnError) { throw errors; // out of Update } }
protected override void OnRowUpdating (RowUpdatingEventArgs value) { if (RowUpdating != null) RowUpdating (this, (SqlRowUpdatingEventArgs) value); }
protected abstract void OnRowUpdating(RowUpdatingEventArgs value);