Clone the database connection, open it, run your query, close and remove the connection. Everything apart cloning has to be done from the thread that is to execute the query.