How to increase Score Count by 1 each time an user use ID

i want to increase the score count of the original poster , when a user use his referal ID , each new user have score 1 by default but when any user register with is ID it should update his Score by additional 1 which make it 2 , i place my code under Row_updated event

public void Row_Updated(Dictionary<string, object> rsold, Dictionary<string, object> rsnew) {
rsnew[“AssignedBy”] = rsold[“ID”];
rsnew[“Score”]= “Score++”;
}

ID is primary key which is auto increment in Users table. when i run my code its not having any effect . Thank you

I think this line:

rsnew[“Score”]= “Score++”;

Should look something like (assuming Score is an int):

rsnew[“Score”]= ((int)rsold[“Score”])++;

public void Row_Updated(Dictionary<string, object> rsold, Dictionary<string, object> rsnew) {
rsnew[“AssignedBy”] = rsold[“ID”];
rsnew[“Score”]= ((int)rsold[“Score”])++;
}



Error CS0445 Cannot modify the result of an unboxing conversion

Try:

rsnew[“Score”]= Convert.ToInt32(rsold[“Score”]) + 1;

it is still not update the field

cant i use store procedure , if user has was invited through a referal code he should input the referal code and the orginal user score should be increase by 1 but if user was not invited by referal code he should just do nothing. i am not sure if i put the code properly.

// Row Updated event
public void Row_Updated(Dictionary<string, object> rsold, Dictionary<string, object> rsnew) {
var row = ExecuteRow(" UPDATE Users
SET Score = Score + 1
WHERE rsold[“ID”] = @AssignedBy ");
}


i try this code below inside my SQL SERVER AND IT WORKS THE WAY IT SHOULD
CREATE Procedure [dbo].[IncreaseCount]

@AssignedBy int
AS

UPDATE Users
SET Score = Score + 1
WHERE ID = @AssignedBy

You should use the Row_Updating server event, not Row_Updated (database is already updated in Row_Updated).

Still not working

i am thinking of using store procedure but i dont know how to write it in asp.net maker and where to place it.

Did you try in Row_Updating server event? What error did you get? Make sure that you have enabled debug mode (Tools → Advanced Settings → Debug) first.

rsnew[“Score”] = Convert.ToInt32(rsold[“Score”]) + 1;

yes u try row updating server event , it doesnt bring out any error it just dont update the original poster score.


can you please show steps on how you we do this in a ASP.NET Maker

if any user register

ID(PRIMARY KEY AUTO INCREMENT) which is the referal code i sent to users email as their referal code ,
NAME : abc
PHONE NUMBER: 0583833333
SCORE : by default set it to 1
ASSIGNEDBY: if you are refer by a register user use his referal code but if you are not leave it blank zero(0) will be assign automatically


if another user register using the above user referal code , we should update the above user score +1


i have done all where i am having issue is to locate the user and update his score base on his referal code. Thank you

Try debugging in Visual Studio 2019, where you can add a break point in the server event, step through the codes and see the values in the variables.