Click here to Skip to main content
15,906,296 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
1) this is my update button coding

C#
int damage = Convert.ToInt16(numericUpDown1.Value);
           UGIcon.Open();
           cmd = new SqlCommand("select * from purchase", UGIcon);
           SqlDataReader s = cmd.ExecuteReader();
           while (s.Read())
           {
               if (toolStripTextBox1.Text != s["cm"].ToString())
               {

                   MessageBox.Show("Please check the name");
               }

           }
           s.Close();
           UGIcon.Close();
           if (textBox2.Text == "")
               {
                   errorProvider1.SetError(textBox2, "Provide Owner name");
               }
               else if (textBox3.Text == "")
               {
                   errorProvider1.SetError(textBox3, "Provide Address");
               }
               else if (numericUpDown2.Value >= damage)
               {
                   MessageBox.Show("check Damage quantity");
               }
               else if ((maskedTextBox1.Text.Trim().Length <= 10))
               {
                   MessageBox.Show("Provide full phone number");
               }
               else
               {
                   UGIcon.Open();
                   cmd = new SqlCommand("update purchase set om='" + textBox2.Text + "', address='" + textBox3.Text + "', phone='" + maskedTextBox1.Text.ToString() + "',baled='" + numericUpDown2.Value + "',paid='" + textBox9.Text + "' where cm='" + toolStripTextBox1.Text + "'", UGIcon);
                   SqlDataReader dr;
                   dr = cmd.ExecuteReader();
                   dr.Close();
                   MessageBox.Show("Details has been updated sucessfully", "Update Window", MessageBoxButtons.OK, MessageBoxIcon.Information);
                   UGIcon.Close();

               }
           }




2)this is my trigger coding



SQL
CREATE TRIGGER [dbo].[TR_STORE_]
   ON  [dbo].[purchase] AFTER UPDATE
AS
BEGIN
    SET NOCOUNT ON;
 
    INSERT INTO yarnhis(ref_id,cm,paid,balance,total,[timestamp])
    SELECT id,cm,paid,balance,total,GETDATE()
    FROM DELETED;
 
END




3)if i click update button this trigger need to be fired, i dont know where to put the code... help me guys... what method i have to create i dont knw anything, can anyone guide me to execute this.... :)
Posted
Updated 3-Jan-13 23:33pm
v5

1 solution

 
Share this answer
 
Comments
selva_1990 4-Jan-13 6:01am    
i m using after update trigger... if i press button tat trigger need to be fired can u provide me simple example to use in c#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900