private void RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { if (GetAutoNumber) { if (e.Status == UpdateStatus.Continue & e.StatementType == StatementType.Insert) { try { //Lay gia tri AutoNumber ID if (this.PrimaryKey[0].AutoIncrement) { SqlCommand cmd = new SqlCommand("Select @@IDENTITY", Conection); e.Row.Table.Columns[0].ReadOnly = false; Object retID = cmd.ExecuteScalar(); if (retID != null) { e.Row[0] = Convert.ToInt16(retID); e.Row.AcceptChanges(); } } } catch (Exception ex) { TLog.WriteErr("MyTable:RowUpdated()", ex.Message); } } } }
private void sqlDataAdapter1_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { NorthwindDataSet.CustomersRow CustRow = (NorthwindDataSet.CustomersRow)e.Row; MessageBox.Show(CustRow.CustomerID.ToString() + " has been updated"); northwindDataSet1.Customers.Clear(); sqlDataAdapter1.Fill(northwindDataSet1.Customers); }
private void daEmployees_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { string strMsg; //响应OnRowUpdated事件,查看RowUpdatedEventArgs属性 strMsg = "更新完成。"; strMsg += "\n数据库中的记录已经被修改。"; MessageBox.Show(strMsg); }
//为一个支持UpdateBehavior.Continue的DataAdapter对象监听RowUpdate事件 private void OnSqlRowUpdated(object sender, SqlRowUpdatedEventArgs rowThatCouldNotBeWritten) { if (rowThatCouldNotBeWritten.RecordsAffected == 0) { if (rowThatCouldNotBeWritten.Errors != null) { rowThatCouldNotBeWritten.Row.RowError = Resources.Data.RowUpdateFailed; rowThatCouldNotBeWritten.Status = UpdateStatus.SkipCurrentRow; } } }
void Adapter_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { if (e.Status == UpdateStatus.Continue && e.StatementType == StatementType.Insert) { int id = 0; using (SqlCommand cmd = new SqlCommand("SELECT IDENT_CURRENT('CarScheduling')", dataAdapter.SelectCommand.Connection)) { id = Convert.ToInt32(cmd.ExecuteScalar()); } e.Row["ID"] = id; } }
private void Adapter_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { //if (e.StatementType == StatementType.Insert) //{ // string sql = "EXEC SP_SLVT @mavt = N'" + e.Row["MAVT"] + "', @sl = " + e.Row["SOLUONG"]; // //SqlTransaction tran; // SqlCommand command = new SqlCommand(sql, DBmanager.connection); // command.ExecuteNonQuery(); //} }
void firimaSatis_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { try { if (e.Row.RowState == DataRowState.Added) { using (SqlCommand cmd = new SqlCommand("Select @@Identity", e.Command.Connection)) { object NewID = cmd.ExecuteScalar(); try { (firmaSatislarBindingSource.Current as DataRowView)["Id"] = NewID; } catch { } } } } catch { } }
}//Col private void My_OnRowUpdate(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { if (e.StatementType == StatementType.Insert) { // reads the identity value from the output parameter @ID object ai = e.Command.Parameters["@NEWID"].Value; this.id = (int)ai; // updates the identity column (autoincrement) DataColumn C = this.MyDataTable.Columns[0]; if (C.ColumnName == "id") { C.ReadOnly = false; e.Row[C] = ai; C.ReadOnly = true; } e.Row.AcceptChanges(); } }
void adapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e) { if (e.StatementType == StatementType.Insert) { var insertedRow = e.Row; try { insertedRow.Table.Columns[0].ReadOnly = false; insertedRow[0] = e.Command.Parameters["NewEmployeeNo"].Value; } catch (Exception) { throw; } finally { insertedRow.Table.Columns[0].ReadOnly = true; } } }
private void dataAdapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e) { string s = System.Enum.GetName(e.StatementType.GetType(), e.StatementType); MessageBox.Show(s); if(e.RecordsAffected < 1) { MessageBox.Show("Concurrency Problem occurred"); e.Status = UpdateStatus.SkipCurrentRow; } }
private void adapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e) { _countUpdated++; }
public void objSqlAdapter_RowUpdated( object sender, SqlRowUpdatedEventArgs e ) { }
private void dataAdapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e) { string s = System.Enum.GetName(e.StatementType.GetType(), e.StatementType); //MessageBox.Show(s); Response.Write("<script>alert('" + s + "')</script>"); if (e.RecordsAffected < 1) { Response.Write("<script>alert(Concurrency Problem occurred)</script>"); //MessageBox.Show("Concurrency Problem occurred"); e.Status = UpdateStatus.SkipCurrentRow; } }
/// <summary> /// Handles the RowUpdated event /// </summary> /// <param name="obj">The object that published the event</param> /// <param name="e">The SqlRowUpdatedEventArgs</param> protected void RowUpdated(object obj, SqlRowUpdatedEventArgs e) { base.RowUpdated(obj, e); }
private void myDataAdapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e) { if (e.StatementType == StatementType.Insert) { e.Row["uid"] = e.Command.Parameters["@getuid"].Value; } }
private void sqlDa_RowUpdated(object sender, SqlRowUpdatedEventArgs e) { Exception exp = null; switch (e.StatementType) { case StatementType.Insert: try { BeginCase("RowInsert"); Compare(drInsert ,e.Row ); } catch(Exception ex) {exp = ex;} finally {EndCase(exp); exp = null;} EventCounter++; break; case StatementType.Delete: try { BeginCase("RowDelete"); Compare(drDelete ,e.Row ); } catch(Exception ex) {exp = ex;} finally {EndCase(exp); exp = null;} EventCounter++; break; case StatementType.Update: try { BeginCase("RowUpdate"); Compare(drUpdate ,e.Row ); } catch(Exception ex) {exp = ex;} finally {EndCase(exp); exp = null;} EventCounter++; break; } }
private void sqlDARepMuestreador_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { }
protected void SQLServerOnRowUpdated(object sender, SqlRowUpdatedEventArgs args) { /* if (args.Status == UpdateStatus.Continue) { SqlCommand idCMD = new SqlCommand("SELECT SCOPE_IDENTITY()", SqlConn); if (sTrans != null) idCMD.Transaction = sTrans; if (args.StatementType == StatementType.Insert) { Object o = idCMD.ExecuteScalar(); //InsertAutoFieldsID = (int)idCMD.ExecuteScalar(); } } */ }
private void m_adpBenutzer_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e) { }
/// <summary> /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed. /// <example> /// sqlrowupdatedeventhandler.BeginInvoke(sender, e, callback); /// </example> /// </summary> public static IAsyncResult BeginInvoke(this SqlRowUpdatedEventHandler sqlrowupdatedeventhandler, Object sender, SqlRowUpdatedEventArgs e, AsyncCallback callback) { if(sqlrowupdatedeventhandler == null) throw new ArgumentNullException("sqlrowupdatedeventhandler"); return sqlrowupdatedeventhandler.BeginInvoke(sender, e, callback, null); }
// handler for RowUpdated event private void OnRowUpdated(object sender, SqlRowUpdatedEventArgs e) { //PrintEventArgs(e); return; }
/// <devdoc> /// Listens for the RowUpdate event on a dataadapter to support UpdateBehavior.Continue /// </devdoc> private void OnSqlRowUpdated(object sender, SqlRowUpdatedEventArgs rowThatCouldNotBeWritten) { if (rowThatCouldNotBeWritten.RecordsAffected == 0) { if (rowThatCouldNotBeWritten.Errors != null) { rowThatCouldNotBeWritten.Row.RowError = Resources.ExceptionMessageUpdateDataSetRowFailure; rowThatCouldNotBeWritten.Status = UpdateStatus.SkipCurrentRow; } } }
protected void RowUpdated(object obj, SqlRowUpdatedEventArgs e) { }
/// <summary> /// 忽略空的更新 /// </summary> /// <param name="sender">引发事件的对象</param> /// <param name="args">事件参数</param> protected static void OnRowUpdated(object sender, SqlRowUpdatedEventArgs args) { if (args.Errors!=null) if(args.Errors is DBConcurrencyException) args.Status=UpdateStatus.SkipCurrentRow; }
static void adapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e) { if (e.StatementType == StatementType.Insert) { DataRow insertedRow = e.Row; DataColumn column = null; foreach (DataColumn col in e.Row.Table.Columns) { if (!col.AutoIncrement) continue; column = col; col.ReadOnly = false; col.AllowDBNull = true; } if (column != null) { try { insertedRow[column.ColumnName] = e.Command.Parameters["New" + column.ColumnName].Value; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { column.ReadOnly = true; } } } }