This issue was caused by the Subcategory not having any content related to it. When the page was loaded, this error would appear.
This issue was resolved by the following.
#1: I added the count to the Where Clause in the SQL Query.
(Demonstration article
SQL Server - How to get only records that have content?«.)
#2: I changed the count to show only Subcategories with Content.