示例#1
0
        private void RowUpdatingHandler(object sender, SqlRowUpdatingEventArgs 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;
            }
        }
        private void RowUpdatingHandler(object sender, SqlRowUpdatingEventArgs e)
        {
            if (e.Status != UpdateStatus.Continue)
            {
                return;
            }

            switch (e.StatementType)
            {
            case StatementType.Delete:
                deleteCommand = e.Command;
                break;

            case StatementType.Insert:
                insertCommand = e.Command;
                break;

            case StatementType.Update:
                updateCommand = e.Command;
                break;

            default:
                return;
            }

            try
            {
                BuildCache(false);

                switch (e.StatementType)
                {
                case StatementType.Delete:
                    e.Command = CreateDeleteCommand(e.Row, e.TableMapping);
                    e.Status  = UpdateStatus.Continue;
                    break;

                case StatementType.Insert:
                    e.Command = CreateInsertCommand(e.Row, e.TableMapping);
                    e.Status  = UpdateStatus.Continue;
                    break;

                case StatementType.Update:
                    e.Command = CreateUpdateCommand(e.Row, e.TableMapping);
                    e.Status  = UpdateStatus.Continue;
                    break;
                }

                if (e.Command != null && e.Row != null)
                {
                    e.Row.AcceptChanges();
                    e.Status = UpdateStatus.SkipCurrentRow;
                }
            }
            catch (Exception exception)
            {
                e.Errors = exception;
                e.Status = UpdateStatus.ErrorsOccurred;
            }
        }
示例#3
0
        private void daEmployees_RowUpdating(object sender, System.Data.SqlClient.SqlRowUpdatingEventArgs e)
        {
            string strMsg;

            //响应OnRowUpdating事件,查看RowUpdatingEventArgs属性
            strMsg  = "开始更新......";
            strMsg += "\n数据库中的记录正在被修改。";
            MessageBox.Show(strMsg);
        }
示例#4
0
 private void myDataAdapter_RowUpdating(object sender, SqlRowUpdatingEventArgs e)
 {
     if (e.StatementType == StatementType.Insert)
     {
         SqlParameter myParamenter = new SqlParameter("@getuid", SqlDbType.Int);
         myParamenter.Direction = ParameterDirection.Output;
         e.Command.Parameters.Add(myParamenter);
         e.Command.CommandText += ";select @getuid = SCOPE_IDENTITY()";
     }
 }
        private void sqlDataAdapter1_RowUpdating(object sender, System.Data.SqlClient.SqlRowUpdatingEventArgs e)
        {
            NorthwindDataSet.CustomersRow CustRow = (NorthwindDataSet.CustomersRow)e.Row;
            DialogResult response = MessageBox.Show("Continue updating " + CustRow.CustomerID.ToString() + "?", "Continue Update?", MessageBoxButtons.YesNo);

            if (response == DialogResult.No)
            {
                e.Status = UpdateStatus.SkipCurrentRow;
            }
        }
示例#6
0
 private void Adapter_RowUpdating(object sender, System.Data.SqlClient.SqlRowUpdatingEventArgs e)
 {
     //tran = DBmanager.connection.BeginTransaction(System.Data.IsolationLevel.Serializable);
     //command.Transaction = tran;
     //try
     //{
     //    command.ExecuteNonQuery();
     //    tran.Commit();
     //    btnReload_Click(null, null);
     //}
     //catch (SqlException ex)
     //{
     //    tran.Rollback();
     //}
 }
示例#7
0
 static void da_RowUpdating(object sender, SqlRowUpdatingEventArgs e)
 {
     Console.WriteLine("----------------------------");
     Console.WriteLine("Command: " + e.Command.CommandText);
     Console.Write("Parameters: ");
     foreach (SqlParameter p in e.Command.Parameters)
     {
         Console.Write(p.Value + "(" + p.SourceVersion + ")" + ", ");
     }
     Console.WriteLine();
     if (e.Row.RowState != DataRowState.Deleted)
     {
         Console.Write("Row: ");
         foreach (object o in e.Row.ItemArray)
         {
             Console.Write(o.ToString() + ", ");
         }
         Console.WriteLine();
     }
     Console.WriteLine("StatementType: " + e.StatementType);
     Console.WriteLine("Status: " + e.Status);
     Console.WriteLine("----------------------------");
 }
		private void RowUpdatingHandler (object sender, SqlRowUpdatingEventArgs e)
		{
			if (e.Status != UpdateStatus.Continue)
				return;

			switch (e.StatementType) {
			case StatementType.Delete:
				deleteCommand = e.Command;
				break;
			case StatementType.Insert:
				insertCommand = e.Command;
				break;
			case StatementType.Update:
				updateCommand = e.Command;
				break;
			default:
				return;
			}

			try {
				BuildCache (false);

				switch (e.StatementType) {
				case StatementType.Delete:
					e.Command = CreateDeleteCommand (e.Row, e.TableMapping);
					e.Status = UpdateStatus.Continue;
					break;
				case StatementType.Insert:
					e.Command = CreateInsertCommand (e.Row, e.TableMapping);
					e.Status = UpdateStatus.Continue;
					break;
				case StatementType.Update:
					e.Command = CreateUpdateCommand (e.Row, e.TableMapping);
					e.Status = UpdateStatus.Continue;
					break;
				}

				if (e.Command != null && e.Row != null) {
					e.Row.AcceptChanges ();
					e.Status = UpdateStatus.SkipCurrentRow;
				}
			}
			catch (Exception exception) {
				e.Errors = exception;
				e.Status = UpdateStatus.ErrorsOccurred;
			}
		}
 private void SqlRowUpdatingHandler(object sender, SqlRowUpdatingEventArgs ruevent)
 {
     base.RowUpdatingHandler(ruevent);
 }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// sqlrowupdatingeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this SqlRowUpdatingEventHandler sqlrowupdatingeventhandler, Object sender, SqlRowUpdatingEventArgs e, AsyncCallback callback)
        {
            if(sqlrowupdatingeventhandler == null) throw new ArgumentNullException("sqlrowupdatingeventhandler");

            return sqlrowupdatingeventhandler.BeginInvoke(sender, e, callback, null);
        }
示例#11
0
 void RowUpdatingHandler(object sender, SqlRowUpdatingEventArgs args)
 {
     base.RowUpdatingHandler(args);
 }
示例#12
0
 public void objSqlAdapter_RowUpdating( object sender, SqlRowUpdatingEventArgs e )
 {
     objLastUpdateRow = e.Row;
 }
		private void SqlHandler2 (object sender, SqlRowUpdatingEventArgs e)
		{
			WriteRowUpdating ("Handler 2:", e);
		}
		private void WriteRowUpdating (string title, SqlRowUpdatingEventArgs e)
		{
			Console.WriteLine (title);

			Console.WriteLine ("Status: {0}", e.Status);
			Console.WriteLine ("StatementType: {0}", e.StatementType);
			WriteCommand ("Command", e.Command);
			Console.WriteLine ("");
		}
    //end callback 

    protected static void adapter_RowUpdating(
  object sender, SqlRowUpdatingEventArgs args)
    {
        if (args.StatementType == StatementType.Update)
        {

        }
    }
 /// <summary>
 /// Handles the RowUpdating event
 /// </summary>
 /// <param name="obj">The object that published the event</param>
 /// <param name="e">The SqlRowUpdatingEventArgs</param>
 protected void RowUpdating(object obj, SqlRowUpdatingEventArgs e)
 {
     base.RowUpdating(obj, e);
 }
示例#17
0
 /// <summary>
 /// 日期类型需要转换
 /// </summary>
 protected void OnAdapterRowUpdating(object sender, SqlRowUpdatingEventArgs e)
 {
     foreach (SqlParameter p in e.Command.Parameters)
     {
         if (p.SqlDbType != SqlDbType.DateTime) continue;
         if (string.IsNullOrEmpty(p.Value.ToString()))
         { p.Value = DBNull.Value; continue; }
         if (DateTime.Parse(p.Value.ToString()).ToString("yyyyMMdd") == DateTime.MinValue.ToString("yyyyMMdd"))
         { p.Value = DBNull.Value; continue; }
     }
 }
示例#18
0
		private void sqlDa_RowUpdating(object sender, SqlRowUpdatingEventArgs 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 SqlRowUpdatingHandler(object sender, SqlRowUpdatingEventArgs ruevent)
 {
     base.RowUpdatingHandler(ruevent);
 }
示例#20
0
 private void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e)
 {
     //PrintEventArgs(e);
     return;
 }
示例#21
0
		void RowUpdatingHandler (object sender, SqlRowUpdatingEventArgs args)
		{
#if NET_2_0
			base.RowUpdatingHandler (args);
#else
			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;
			}
#endif
		}
示例#22
0
		void RowUpdatingHandler (object sender, SqlRowUpdatingEventArgs args)
		{
			base.RowUpdatingHandler (args);
		}