petre ricardo

petre ricardo

  • NA
  • 194
  • 0

could any one show what's wrong with my stored procedure?

Nov 12 2009 11:04 AM


I have writtent the following code to do a simple update operation, UI is a DataGrid according to my test new data passes to the
Update() also the orignal data was preserved and the problem in in the update stored procedure.. could any one see whats the problem is?
I have the folllwong in update() with the code:
 

  public int Update(int iEmpIndex, string strPassword, string strFirstName,
                            string strLastName, int iDesigIndex, int iUsedAnnualLeaves,
                            int iUsedSickLeaves, DateTime enteredate, DateTime updatedDate)
        {
            try
            {
                //updating the DB: VALUES PASSED CORRECTLY BUT DOESNT PERFORM THE TASK
                return empAdapter.Update(strPassword, strFirstName, strLastName, iDesigIndex,
                    iUsedAnnualLeaves, iUsedSickLeaves, enteredate, updatedDate, this.OldEmpIndex,
                    this.OldPassword, this.OldFirstName, this.OldLastName, this.OldDesigIndex,
                    this.OldUsedAnnualLeaves, this.OldUsedSickLeaves, this.OldEnteredDate,
                    this.OldUpdatedDate);
            }
            catch
            {
                throw;
            }
        }
thsi update satement maps to the stored procedure that has the followin SQL query:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[ProcUpdateEmployee]
(
 @Password nvarchar(50),
 @FirstName nvarchar(50),
 @LastName nvarchar(50),
 @DesigIndex int,
 @UsedAnnualLeaves int,
 @UsedSickLeaves int,
 @EntryDate datetime,
 @UpdatedDate datetime,
 @Original_EmpIndex int,
 @Original_Password nvarchar(50),
 @Original_FirstName nvarchar(50),
 @Original_LastName nvarchar(50),
 @Original_DesigIndex int,
 @Original_UsedAnnualLeaves int,
 @Original_UsedSickLeaves int,
 @Original_EntryDate datetime,
 @Original_UpdatedDate datetime,
 @EmpIndex int
)
AS
 SET NOCOUNT OFF;
UPDATE [tblEmployees]
SET
[Password] = @Password,
[FirstName] = @FirstName,
[LastName] = @LastName,
[DesigIndex] = @DesigIndex,
[UsedAnnualLeaves] = @UsedAnnualLeaves,
[UsedSickLeaves] = @UsedSickLeaves,
[EntryDate] = @EntryDate,
[UpdatedDate] = @UpdatedDate
WHERE (([EmpIndex] = @Original_EmpIndex)
AND
([Password] = @Original_Password)
AND
([FirstName] = @Original_FirstName)
AND
([LastName] = @Original_LastName)
AND
([DesigIndex] = @Original_DesigIndex)
AND
([UsedAnnualLeaves] = @Original_UsedAnnualLeaves)
AND
([UsedSickLeaves] = @Original_UsedSickLeaves)
AND
([EntryDate] = @Original_EntryDate)
AND
([UpdatedDate] = @Original_UpdatedDate));
 
SELECT EmpIndex, Password, FirstName, LastName, DesigIndex, UsedAnnualLeaves, UsedSickLeaves, EntryDate, UpdatedDate FROM tblEmployees WHERE (EmpIndex = @EmpIndex)

But those two dont work... eg.: if i chaneg the value in FirstName from John to Jon, update doesnt happen?
why this happense?
TY

Answers (4)