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: -
private void cmdbutton_Click(object sender, System.EventArgs e)
-
{
-
-
-
HtmlInputHidden objHid;
-
HtmlInputHidden objHidden;
-
HtmlInputRadioButton rdoButton;
-
DataGridItem item;
-
for (int counter = 0; counter <= this.gvEmployee.Items.Count - 1; counter++)
-
{
-
item = gvEmployee.Items[counter];
-
rdoButton = ((HtmlInputRadioButton)(item.FindControl("rdoEmployeeNominationID")));
-
objHidden = ((HtmlInputHidden)(item.FindControl("hidEmployeeNominationID")));
-
objHid = ((HtmlInputHidden)(item.FindControl("hidDatecreated")));
-
if (!(rdoButton == null & !(objHidden == null)& !(objHid==null)))
-
{
-
// if (rdoButton.Checked == true)
-
// {
-
// Response.Write(objHidden.Value);
-
// Response.Write("This is the Employee Of the Month");
-
// return;
-
-
if (rdoButton.Checked == true)
-
{
-
-
-
-
string employee=objHidden.Value;
-
-
-
SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]);
-
-
SqlCommand objCmd = new SqlCommand("up_updateEmployeeNominations",oConn);
-
objCmd.CommandType = CommandType.StoredProcedure;
-
objCmd.Parameters.Add(new SqlParameter("@employeenominationid",employee));
-
SqlParameter datecreated = new SqlParameter("@datecreated", SqlDbType.DateTime);
-
datecreated.Direction = ParameterDirection.Output;
-
objCmd.Parameters.Add(datecreated);
-
-
oConn.Open();
-
objCmd.ExecuteNonQuery();
-
oConn.Close();
-
-
-
this.lblMassage.Text="This is Employee of the Month";
-
}
-
-
}
-
-
-
}
-
}
-
-
-
and the store procedure is like this -
CREATE PROCEDURE [dbo].[up_updateEmployeeNominations]
-
(
-
-
@EmployeeNominationID int,
-
@datecreated datetime output --varcahr(50)
-
-
)
-
as
-
-
-
update Reason
-
set EmployeeSelected='1'
-
from reason
-
-
where
-
reason.EmployeeNominationID=@EmployeeNominationID and
-
reason.datecreated =@datecreated
-
-
Set @datecreated =@datecreated
-
GO
-
-
5 1145
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.
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 -
private void cmdbutton_Click(object sender, System.EventArgs e)
-
{
-
-
-
-
HtmlInputHidden objHidden;
-
HtmlInputRadioButton rdoButton;
-
DataGridItem item;
-
for (int counter = 0; counter <= this.gvEmployee.Items.Count - 1; counter++)
-
{
-
item = gvEmployee.Items[counter];
-
rdoButton = ((HtmlInputRadioButton)(item.FindControl("rdoEmployeeNominationID")));
-
objHidden = ((HtmlInputHidden)(item.FindControl("hidEmployeeNominationID")));
-
-
if (!(rdoButton == null & !(objHidden == null)))
-
{
-
// if (rdoButton.Checked == true)
-
// {
-
// Response.Write(objHidden.Value);
-
// Response.Write("This is the Employee Of the Month");
-
// return;
-
-
if (rdoButton.Checked == true)
-
{
-
-
string employee=objHidden.Value;
-
-
-
-
SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]);
-
-
SqlCommand objCmd = new SqlCommand("up_updateEmployeeNominations",oConn);
-
objCmd.CommandType = CommandType.StoredProcedure;
-
objCmd.Parameters.Add(new SqlParameter("@employeenominationid",employee));
-
SqlParameter datecreated = new SqlParameter("@datecreated", SqlDbType.DateTime);
-
datecreated.Direction = ParameterDirection.Output;
-
objCmd.Parameters.Add(datecreated);
-
-
oConn.Open();
-
objCmd.ExecuteNonQuery();
-
oConn.Close();
-
-
-
this.lblMassage.Text="This is Employee of the Month";
-
}
-
-
}
-
-
-
}
-
}
-
-
OK, have you checked that the record with this data exists: - where
-
reason.EmployeeNominationID=@EmployeeNominationID and
-
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: - where
-
reason.EmployeeNominationID=@EmployeeNominationID
with out this: - and reason.datecreated =@datecreated
[/code].
Try that and let's see how it goes. if not, then whe can look something else.
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 .
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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,...
|
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.
...
|
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...
| |
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...
|
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)...
|
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...
|
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:
...
|
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,...
|
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,...
| |
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: 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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |