You need to include checks after the GetObject() and ExecQuery - the error condition will help identify the cause of the problem.