what i want to do is while user click the link, the clicks will increase by 1 but i failed to to do=(
output
Could not find stored procedure ‘updateMovieClicks’How to win in share?’,’64’
my stored procedure
ALTER PROCEDURE updateMovieClicks
(
@movieTitle varchar(50),
@movieClicks int
)
AS
update MovieListTable set movieClicks=@movieClicks where movieTitle=@movieTitle;
my programs code on page load
conn.Open();
SqlCommand cmdIncreaseMovieClicks = new SqlCommand("updateMovieClicks'" +
Session["videoName"].ToString() + "','" + clicksIncrease + "'", conn);
SqlParameter movieTitle = new SqlParameter();
SqlParameter movieClicks = new SqlParameter();
cmdIncreaseMovieClicks.CommandType = CommandType.StoredProcedure;
cmdIncreaseMovieClicks.Parameters.Add("@movieClick", SqlDbType.Int).Value
= clicksIncrease+1;
cmdIncreaseMovieClicks.ExecuteNonQuery();
conn.Close();
Your error is ocurring because the system thinks you are trying to find a stored procedure called
'updateMovieClicks'How to win in share?','64'. This is because you have concatenated your parameters in a string with your stored procedure name.When specifying that a command is of type
StoredProcedurethen you add your parameters seperately to the command text. Therefore only the stored procedure name goes in the command text, and the parameters are added as seperate objects to the SqlCommand.Here I’ve also improved your Stored Procedure query so that the
movieClicksis calculated at SQL level.