That is because you, yourself, personally are throwing this exception in your code when there is no record found in the database.
if (obj != null)
return obj.ToString();
else
throw new Exception("No records");
This line of code is intended to do what you're seeing. It will see, if there is any record, ortherwise throw the exception; with the parameter as the reason or
Message
.
To ignore the exception being raised, please remove this line,
throw new Exception("No records");
Then it won't throw the exception, instead you can show a message pop up to the user with this value.