473,473 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Update is not working

67 New Member
i am tring to update the records it is not giving me any error going through the appilication but it is not updating the data base i am not able to find the problem if any one know about this then please help me
my cod eis 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.  
  26.  
  27.  
  28. string employee=objHidden.Value;
  29.  
  30.  
  31.                         SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]); 
  32.  
  33.                         SqlCommand objCmd = new SqlCommand("up_updateEmployeeNominations",oConn);
  34.                         objCmd.CommandType = CommandType.StoredProcedure;
  35.                         objCmd.Parameters.Add(new SqlParameter("@employeenominationid",employee));
  36.                         SqlParameter datecreated = new SqlParameter("@datecreated", SqlDbType.DateTime); 
  37.                         datecreated.Direction = ParameterDirection.Output; 
  38.                         objCmd.Parameters.Add(datecreated);
  39.  
  40.                         oConn.Open();
  41.                         objCmd.ExecuteNonQuery();
  42.                         oConn.Close();
  43.  
  44.  
  45.                     this.lblMassage.Text="This is Employee of the Month";
  46.                     }
  47.  
  48.         }
  49.  
  50.  
  51.     } 
  52.  
  53.  
  54.  

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 datetime output --varcahr(50)
  6.  
  7. )
  8. as
  9.  
  10.  
  11. update  Reason 
  12. set    EmployeeSelected='1'
  13. from reason
  14.  
  15. where
  16. reason.EmployeeNominationID=@EmployeeNominationID and  
  17. reason.datecreated =@datecreated 
  18.  
  19.  Set @datecreated =@datecreated
  20. GO
  21.  
  22.  
Sep 13 '07 #1
5 1145
dotneto
36 New Member
Sorry, I'm maybe not understanding but i'll guess, maybe
reason.datecreated =@datecreated is what makes it doesn't updates, because you are not passing any meaningful value to this parameter. Is an output parameter and it doesn't seem to be initialized. Maybe it makes that the updates never happens.


Hope it helps.
Sep 13 '07 #2
preeti13
67 New Member
Hey i tried that way but it did not work i think the problem is in the application because appication is not picking the vaule of the date created i am not able to find the probelm please help me with this
Expand|Select|Wrap|Line Numbers
  1. private void cmdbutton_Click(object sender, System.EventArgs e)
  2.         {
  3.  
  4.  
  5.  
  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.  
  15.                 if (!(rdoButton == null & !(objHidden == 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.  
  26.                         string employee=objHidden.Value;
  27.  
  28.  
  29.  
  30.                         SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]); 
  31.  
  32.                         SqlCommand objCmd = new SqlCommand("up_updateEmployeeNominations",oConn);
  33.                         objCmd.CommandType = CommandType.StoredProcedure;
  34.                         objCmd.Parameters.Add(new SqlParameter("@employeenominationid",employee));
  35.                         SqlParameter datecreated = new SqlParameter("@datecreated", SqlDbType.DateTime); 
  36.                         datecreated.Direction = ParameterDirection.Output; 
  37.                         objCmd.Parameters.Add(datecreated);
  38.  
  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.  
  52.  
Sep 13 '07 #3
dotneto
36 New Member
OK, have you checked that the record with this data exists:
Expand|Select|Wrap|Line Numbers
  1. where
  2. reason.EmployeeNominationID=@EmployeeNominationID and  
  3. reason.datecreated =@datecreated 
because I don't see why you compare with the @datecreated parameter, I think that parameter doesn't have any value and that makes that the update never happens.
Is employee nomination Id a unique value?, if so, try this part:
Expand|Select|Wrap|Line Numbers
  1. where
  2. reason.EmployeeNominationID=@EmployeeNominationID 
with out this:
Expand|Select|Wrap|Line Numbers
  1. and  reason.datecreated =@datecreated 
[/code].

Try that and let's see how it goes. if not, then whe can look something else.
Sep 14 '07 #4
preeti13
67 New Member
thanks very much to halping me but this is not a solution either because. i have one to many relationship into the data base i means each record has a uniqe id value but it is nominated mre then one time like id number 1 has a 5 times in there but any ways i got the solution i have a reason id uniqe in there so i am dispalying the data using the reason id. once again thanks very much for helping me with this problem .
Sep 14 '07 #5
dotneto
36 New Member
thanks very much to halping me but this is not a solution either because. i have one to many relationship into the data base i means each record has a uniqe id value but it is nominated mre then one time like id number 1 has a 5 times in there but any ways i got the solution i have a reason id uniqe in there so i am dispalying the data using the reason id. once again thanks very much for helping me with this problem .
i'm glad you found the solution
bye.
Sep 17 '07 #6

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

Similar topics

17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
3
by: Shapper | last post by:
Hello, I have created 3 functions to insert, update and delete an Access database record. The Insert and the Delete code are working fine. The update is not. I checked and my database has all...
5
by: HydroSan | last post by:
Having a bit of a problem getting UPDATE working. The project in question is a simple MySQL VB.NET frontend, allowing Insertion, Selection, and others. Well, I've gotten Drop and Insert working,...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
2
by: Miro | last post by:
I will ask the question first then fumble thru trying to explain myself so i dont waste too much of your time. Question / Statement - Every mdb table needs a PrimaryKey ( or maybe an index - i...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
6
by: Nuzzi | last post by:
Hello All, I have two pages that are very similar. One is working, one is not. Here is the code for both: Page 1 (Working): protected void btn_update_Click(object sender, EventArgs e)...
3
by: Brad Baker | last post by:
I have a formview with a datasource that contains a select and update command. The select statement works fine but the update command doesn't seem to be working. After some troubleshooting I have...
3
by: Dilruba | last post by:
asp, vbscript, Ms Access I am using vbscript to insert & update ms accees. Insert operation is working , but update operation is not working. I have used the following codes: ...
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.