Did you use the debugger to debug your code?
What if either con, stmt or res are nullptrs? The example relies on them not being nullptrs, but if they are, your program will crash as it does.