Hi Nedash,
If you needs solution than please read my this reply very carefully.
Last time I only suggeted you to remove duplicate ExecuteScalar()
.
And for your better information its not caused by that. We had just removed nonsence code.
Now listen what you need to do.
1) Leave ID setting logic as it is.
2) You need to update logic for Result only. Currently you have set Result = ID is wrong. (I suggeted this because you were getting value in both variables by using ExecuteScalar()
.)
Now get value of @Result by OUTPUT parameter make @Result as OUTPUT parameter. I know that you know how to use output parameter yet if you forgotten please refer the following link.
(Make sure the purpose of the link I am suggesting is to refer how to get value using Output parameter.)
1. OUTPUT Parameter.