Last post May 30, 2012 03:40 AM by gopalanmani
May 30, 2012 03:20 AM|direct_tarun|LINK
hello everyone i am describing my problem that i am sending a autogenerated e-mail....in which i am sending a link to activate an account....in which i have to apply an update commant....which is given below.
Now i am confused with that how to know whether data has been updated or not in table....there is an property recordsAffected but if a user already activated his account.
In that case RecorrdAffected will be zero so how i could i come to know....whether the account has been activated or he is trying to re-activate it...or he trying to activate a wrong account....
command.CommandText = "update xxxx set ACT_STAT = 1 where P_ID = '" + name + "'";
May 30, 2012 03:28 AM|nijhawan.saurabh|LINK
When you do an update, it'd immediately return rows updated: It Return Number of Records Affected
In case you are sending email first and then doing an update and you have this concern saying, before your update user may read his mail and activate and from there another update command may run before your's then there's a problem with your model.
User being activated and mail being sent are two different things and should be stored in two diff places(columns)
May 30, 2012 03:40 AM|Mudasir.Khan|LINK
create a SP in that
1) first check if the account is already activated then retun 1000
2) if not activated then run the update statement and return 100
3) use try and catch if any exception then return -1
and so on
May 30, 2012 03:40 AM|gopalanmani|LINK
@@ROWCOUNT will give you the number of records affected by a SQL Statement.
The following example executes an UPDATE statement and uses
@@ROWCOUNT to detect if any rows were changed
UPDATE HumanResources.Employee SET JobTitle = N'Executive' WHERE NationalIDNumber = 123456789
IF @@ROWCOUNT = 0
PRINT 'Warning: No rows were updated';using Stored Procedure,
Register an out parameter for the stored procedure, and set the value based on @@ROWCOUNT if using SQL Server. Use SQL%ROWCOUNT if you are using Oracle.
Mind that if you have multiple INSERT/UPDATE/DELETEs, you'll need a variable to store the result from @@ROWCOUNT for each operation.