Catching encoding exception while applying parameters to record query