Better database query error handling.

When returning due to an error, close the rows object.  Additionally,
when rows.Next returns false, check that it was caused by an error.