public int ExecuteReturnVal() { int result = 0; using (SqlConnection sqlConnection = new SqlConnection(Constants.Config.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand(this.Name, sqlConnection); sqlCommand.set_CommandType(4); sqlCommand.set_CommandTimeout(120); SqlParameter sqlParameter = new SqlParameter("@RETURN", 8); sqlParameter.set_Direction(6); sqlCommand.get_Parameters().Add(sqlParameter); IEnumerator enumerator = this.StoredProcParams.GetEnumerator(); try { while (enumerator.MoveNext()) { StoredProcParam storedProcParam = (StoredProcParam)enumerator.get_Current(); sqlCommand.get_Parameters().Add(storedProcParam.ParamID, storedProcParam.ParamValue); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } sqlConnection.Open(); sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); result = (int)sqlParameter.get_Value(); } return result; }