Если результат запроса пустой, то в строке с DataSet1.Close получаем следующее исключение
Project 1.exe raised exception class EOleException with message 'Either BOF or EOF is True, or
the current record has been deleted. Requested operation requires a current record'. Process stopped.
Use Step or Run to continue.