I have a stored procedure to update the status by changing the bool value from 1 to 0. I am passing the user id to the stored procedure. I just need to update the user status only. But now it's not doing that.
CREATE PROCEDURE [dbo].[UpdateStatus]
@userID INT
AS
BEGIN
UPDATE [dbo].[User]
SET Status = 0
WHERE Id = @userID
END
I am calling this stored procedure:
public User UpdateStatus(string UserId)
{
User userDetails = new User();
try
{
using (SqlConnection sqlConnection = new SqlConnection(connection.GetConnectionString()))
{
sqlConnection.Open();
SqlCommand cmd = new SqlCommand("UpdateStatus", sqlConnection);
cmd.Parameters.Add(new SqlParameter("@userID", UserId));
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
userDetails.DisplayName = reader["DisplayName"].ToString();
}
}
sqlConnection.Close();
}
}
catch(Exception ex)
{
//ex.Message;
}
return userDetails;
}
I am calling the UpdateStatus function. But it's not updating the status in the database
RETURNstatus, which'll likely be0for success.OUTPUTclause, @MonkeyDLuffy