コード例 #1
0
        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);
                    }
                }
            }
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        private void daEmployees_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e)
        {
            string strMsg;

            //响应OnRowUpdated事件,查看RowUpdatedEventArgs属性
            strMsg  = "更新完成。";
            strMsg += "\n数据库中的记录已经被修改。";
            MessageBox.Show(strMsg);
        }
コード例 #4
0
        //为一个支持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;
				}
			}
		}
コード例 #5
0
 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;
     }
 }
コード例 #6
0
        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();

            //}
        }
コード例 #7
0
        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 { }
        }
コード例 #8
0
ファイル: clsGenericQuery.cs プロジェクト: campbesj/LoadTruck
        }//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();
            }
        }
コード例 #9
0
        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;
                }
            }
        }
コード例 #10
0
ファイル: MyNotes.cs プロジェクト: mroNNorm/CSCI473MyNote
 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;
     }
 }
コード例 #11
0
 private void adapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e)
 {
     _countUpdated++;
 }
コード例 #12
0
 public void objSqlAdapter_RowUpdated( object sender, SqlRowUpdatedEventArgs e )
 {
 }
コード例 #13
0
 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;
     }
 }
コード例 #14
0
 /// <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);
 }
コード例 #15
0
ファイル: RecordSet.cs プロジェクト: Donnie888/LxServer
 private void myDataAdapter_RowUpdated(object sender, SqlRowUpdatedEventArgs e)
 {
     if (e.StatementType == StatementType.Insert)
     {
         e.Row["uid"] = e.Command.Parameters["@getuid"].Value;
     }
 }
コード例 #16
0
		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;
			}

		}
コード例 #17
0
 private void sqlDARepMuestreador_RowUpdated(object sender, System.Data.SqlClient.SqlRowUpdatedEventArgs e)
 {
 }
コード例 #18
0
 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();
         }
     }
     */
 }
コード例 #19
0
 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);
        }
コード例 #21
0
ファイル: XTRMWorkflow.cs プロジェクト: cs180011/XTRM
 // handler for RowUpdated event
 private void OnRowUpdated(object sender, SqlRowUpdatedEventArgs e)
 {
     //PrintEventArgs(e);
     return;
 }
コード例 #22
0
 /// <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;
         }
     }
 }
コード例 #23
0
 protected void RowUpdated(object obj, SqlRowUpdatedEventArgs e)
 {
 }
コード例 #24
0
		/// <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;
		}
コード例 #25
0
ファイル: TableExplorer.cs プロジェクト: BHovorunets/VLib
 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;
             }
         }
     }
 }