To close the connection with the database when you no longer need to use it:
int rc; rc = qdb_disconnect(dbhandle); if (rc == -1) { fprintf(stderr, "Disconnect failed: %s\n", strerror(errno)); }