This means that the open is failing .. and that means the select SQL has an error.

I would put a dump after the open.

Run the program. If the same error occurs you want to inspect the dump SQLCode, SQLState and other SQL variables. In there you will find a more complete description of the error and the code and state of the error. Then you will be able to solve the error.