+1  A: 

Are you sure that it isn't crashing on:

s->setBlob(1, &stream);

Check the debugger to make sure that s isn't NULL, or a crap value.

Magnus Skog
No, Im stepping through line by line. Crashes in non-debug mode too.