473,728 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting the probelm with updating the database

67 New Member
i have a two tables employeenominat ions and reason if someone storing a data first time it will store into the employeenominat ions 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.         {
  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; 
  23.                     if (rdoButton.Checked == true) 
  24.                     { 
  25.                         //this.lblMassage .Text="This is Employee of the Month";
  27.                         string date=objHid.Value ;
  28.                         string employee=objHidden.Value;
  29.                         string datecreated;
  30.                         datecreated=Request.QueryString["datecreated"];
  33.                         SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]); 
  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();
  44.                     this.lblMassage.Text="This is Employee of the Month";
  45.                     }
  47.         }
  50.     } 
And the store procedure is like this:

Expand|Select|Wrap|Line Numbers
  1. CREATE  PROCEDURE [dbo].[up_updateEmployeeNominations]
  2. (
  4.  @EmployeeNominationID int
  5. @datecreated varchar(50)
  6. )
  7. as
  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
Sep 10 '07 #1
0 1047

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

Similar topics

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? 1) simply UPDATING the values for all fields in the table, whether or not any particular field has actually changed 2) running a second SELECT statement and comparing the $_POST vars to the returned values, and only UPDATING those that have...
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; foreach ($resultArray as $data) { $tableName = mysql_field_table($result, $i);
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, then written to the database... or at least that's what's supposed to be happening. Unfortunately, I've discovered that while it appears that when I create a new record/row I'm successfully updating the Access database, once the Update is...
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 two fields: a primary key and another holding a string. In table B there are three fields: a primary key, a foreign key (which links to the primary key in A) and other field holding a string.
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 functions can give me. But what is the magic behind classes? i mean, the documentation i find. Most use the class Person as the example. So how would having a person class help me. It seems that i am writing more code than less because i am...
by: vijaykumars | last post by:
+-----------------------------------------------------------------------------+ Summaries: +-----------------------------------------------------------------------------+ Installation Summary -------------------- Name Level Part Event Result ------------------------------------------------------------------------------- db2_08_01.essg USR APPLY ...
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 action buttons, such as "Edit", "Add", and "Comment". Since I do not know how many rows of data will be retrieved - and therefore how many buttons I need - I am using button arrays for each button, like so: echo "<input type=\"submit\"...
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 that basically opens a dataset for each of the tables that needs updating, this dataset selects all rows with the new column and the exception that arises when the column dies not exist is caught and dealt with. It works fine with one exception and...
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 uby/Rails. I started it in Perl and gave up on Perl as I went from the 'display the database information on the web page' to the 're-display the information from the database and allow the user to update the database using the web page' stage and realized...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.