Maybe the database causes the disconnection? My guess is that you shouldn't use QDataStream, it does something more than just stream the data. Try using QTextStream instead.

Anyway, maybe you should write your own database driver for that database?