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)
|
petre ricardoPosted Nov 14, 2009, 6:04 AM
Thanks for your efforts on solving the problem : ) i really appriciate it..... : )
In mys post i have mentioned two issues with my code it was written to update and throw errors on concurrecy violations. However you were able solve the update it (works perfectly fine) but the Exception DBConccurectException is not thrown by the program in a concurrecy violation.
So the second issue was not solved : (
I've debuged it (i havent made any alterations to your code) i figured it doesnt perform any updated on concurrecy violations but it doesnt throw the exception...
Any ideas on why it doesnt throw this exception in concurrency violations?
Thanks
Kirtan PatelPosted Nov 14, 2009, 2:02 AM
Congrats !!
+[Problem Solved]
the problem was you were comparing the same EmpIndex Two Times well Primary Key of table is EmpIndex so no need to Compare it two times Like below
Where EmpIndex = @OldEmpIndex,
and Again
EmpIndex = @EmpIndex
and I have also Modified Braces of the Stored procedure in Conditions
this was causing problem I have attached Corrected Database Files and Your Solution files you provided
I have Changed The Connection String in app.Config for connecting to my SQL Server.
so just change it according to your SQL Server Configuration again :)
Now Application Updates Perfectly :)
Here is Your Solution Files
Download Project Files
and Friend,
Dont forget to mark "Do you like this answer" check box :)
petre ricardoPosted Nov 12, 2009, 11:58 AM
TY
Petre
Kirtan PatelPosted Nov 12, 2009, 11:24 AM
Can you Provide me the Database ???? or Project Files (zip)
because cant figure out by just seeing code :)
just upload the zip at http://mediafire.com
and mail me the download link
at
[email protected]
Thank you :)