Why you are twice executing this query? In addition problem seems that your query returning NULL causing exception. Try this
command.CommandText = "SELECT COUNT(*) FROM " + database +
".Metabolites " +
"WHERE MetaboliteID = " +
"'" + metNo + "'";
object tCount = command.ExecuteScalar();
int count = 0;
if (tCount != null)
count = (int)tCount;