472,110 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,110 software developers and data experts.

getting the probelm with updating the database

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
0 945

Post your reply

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

Similar topics

11 posts views Thread by Jason | last post: by
4 posts views Thread by ChronoFish | last post: by
4 posts views Thread by Geoff | last post: by
6 posts views Thread by nephish | last post: by
6 posts views Thread by sgottenyc | last post: by
2 posts views Thread by Sid Price | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.