By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,742 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,742 IT Pros & Developers. It's quick & easy.

getting the probelm with updating the database

P: 67
i have a two tables employeenominations and reason if someone storing a data first time it will store into the employeenominations table if name is already exist it will store into the reason table and i an dispaly the data by my month the probelm i sthat if i try to update the data from auguest month its updating the same employee who is nominated in next month as well because the person has a same id now i am trying to get the date into the url so it can pick the person for updating by date but it is not passing the date what should i do please help me .my code is look like this.
Expand|Select|Wrap|Line Numbers
  1. private void cmdbutton_Click(object sender, System.EventArgs e)
  2.         {
  3.  
  4.           //
  5.             HtmlInputHidden objHid;
  6.             HtmlInputHidden objHidden; 
  7.             HtmlInputRadioButton rdoButton; 
  8.             DataGridItem item; 
  9.             for (int counter = 0; counter <= this.gvEmployee.Items.Count - 1; counter++) 
  10.             { 
  11.                 item = gvEmployee.Items[counter]; 
  12.                 rdoButton = ((HtmlInputRadioButton)(item.FindControl("rdoEmployeeNominationID"))); 
  13.                 objHidden = ((HtmlInputHidden)(item.FindControl("hidEmployeeNominationID"))); 
  14.                objHid = ((HtmlInputHidden)(item.FindControl("hidDatecreated"))); 
  15.                 if (!(rdoButton == null & !(objHidden == null)& !(objHid==null))) 
  16.                 { 
  17. //                    if (rdoButton.Checked == true) 
  18. //                    { 
  19. //                        Response.Write(objHidden.Value); 
  20. //                        Response.Write("This is the Employee Of the Month");
  21. //                        return; 
  22.  
  23.                     if (rdoButton.Checked == true) 
  24.                     { 
  25.                         //this.lblMassage .Text="This is Employee of the Month";
  26.  
  27.                         string date=objHid.Value ;
  28.                         string employee=objHidden.Value;
  29.                         string datecreated;
  30.                         datecreated=Request.QueryString["datecreated"];
  31.  
  32.  
  33.                         SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]); 
  34.  
  35.                         SqlCommand objCmd = new SqlCommand("up_updateEmployeeNominations",oConn);
  36.                         objCmd.CommandType = CommandType.StoredProcedure;
  37.                         objCmd.Parameters.Add(new SqlParameter("@EmployeeNominationID",employee));
  38.                         objCmd.Parameters.Add(new SqlParameter("@datecreated",datecreated));
  39.                             oConn.Open();
  40.                         objCmd.ExecuteNonQuery();
  41.                         oConn.Close();
  42.  
  43.  
  44.                     this.lblMassage.Text="This is Employee of the Month";
  45.                     }
  46.  
  47.         }
  48.  
  49.  
  50.     } 
  51.  
And the store procedure is like this:

Expand|Select|Wrap|Line Numbers
  1. CREATE  PROCEDURE [dbo].[up_updateEmployeeNominations]
  2. (
  3.  
  4.  @EmployeeNominationID int
  5. @datecreated varchar(50)
  6. )
  7. as
  8.  
  9. update EmployeeNominations
  10. set  EmployeeSelected='1'
  11. from employeenominations,reason
  12. where
  13.    dbo.employeenominations. EmployeeNominationID=@EmployeeNominationID and  datepart (m,dbo.reason.datecreated)=@datecreated
  14. GO
  15.  
  16.  
  17.  
Sep 10 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.