By like below , we can call SP from C# . Here I am gonna show how a SP with Param can be called , which is little tricky rather than simple SP .
My SP name is ::: spU_ChangeProjectStatus Click Here to view the SP .
The SP has a param named @tblProjects_ID , and I am filling that param with projectId variable .
public static bool ChangeProjectStatus(int projectId)
using (SqlConnection cn = new SqlConnection(DBConnector.GetConnectionStringFromServer()))
SqlCommand cmd = new SqlCommand("spU_ChangeProjectStatus", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@tblProjects_ID", SqlDbType.Int).Value = projectId;
catch (Exception ex)
// Logger will be added here Later