473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 1026

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

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
4
by: ChronoFish | last post by:
In PHP you can retrieve the table.column name of a MySQL query doing something like this: $result = mysql_query($query, $dbConnection); $resultArray = mysql_fetch_row($result); $i = 0;...
4
by: Frnak McKenney | last post by:
I'm using an in-core DataSet as an image of my application's 'database' (a multi-table Access97 mdb file). Updates are made to the DataTables within the DataSet via forms with bound TextBoxes,...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
6
by: nephish | last post by:
Hey there all. i have been looking to simplify my huge website that i wrote while learning php. now its a spaghetti mess. So, i wanted to simplify it. Now, i see the functionality that defining...
1
by: vijaykumars | last post by:
+-----------------------------------------------------------------------------+ Summaries: +-----------------------------------------------------------------------------+ Installation...
6
by: sgottenyc | last post by:
Hello, If you could assist me with the following situation, I would be very grateful. I have a table of data retrieved from database displayed on screen. To each row of data, I have added...
2
by: Sid Price | last post by:
I have an application that has already been deployed and we need to add a new column to some of the tables in the application database. We are using an access database. We have a solution working...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.