As Per the Above Code You Have To Pass 5 Parameters While Executing the Procedure
1 : UserName
2 : Password
3 : Country
4 : Email
5 : UserId
In Your C# Code Your are Passing Only 4 Parameters while Executing the Procedure See the Below Code :
SqlConnection con = new SqlConnection("conn");
con.Open();
SqlCommand cmd = new SqlCommand("sp_UserDetails", con);
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("UserName", bobj.UserName));
cmd.Parameters.Add(new SqlParameter("Password", bobj.Password));
cmd.Parameters.Add(new SqlParameter("Country", bobj.Country));
cmd.Parameters.Add(new SqlParameter("Email", bobj.Email));
cmd.Parameters.Add(new SqlParameter("UserId", bobj.UserId));
cmd.ExecuteNonQuery();
}
Or Else Remove the UserID Parameter From Your Procedure If Not Required.
ALTER PROCEDURE [dbo].[sp_UserDetails]
(
@UserName nvarchar(100),
@Password nvarchar(50),
@Country nvarchar(50),
@Email nvarchar(100)
)
AS
INSERT INTO RegistrationTable
(
UserName,
Password,
Country,
Email
)
VALUES
(
@UserName,
@Password,
@Email,
@Country
)
SELECT
@@Identity