Originally Posted by
faldżip
and where did you add those braces { } which make this code work?
like this:
db.setHostName("localhost");
db.setDatabaseName("dbname");
db.setUserName("user");
db.setPassword("secret");
db.open();
{
query.prepare("SELECT col FROM table");
query.exec();
query.next();
}
db.close();
QSqlDatabase db=QSqlDatabase::addDatabase("QMYSQL","connection");
db.setHostName("localhost");
db.setDatabaseName("dbname");
db.setUserName("user");
db.setPassword("secret");
db.open();
{
QSqlQuery query(db);
query.prepare("SELECT col FROM table");
query.exec();
query.next();
}
db.close();
QMessageBox::information(this,"DEBUG","Done");
To copy to clipboard, switch view to plain text mode
Originally Posted by
S.wysota
I'd say it's a normal thing to get a warning (but not a segfault). If QSqlQuery object is still alive while the database connection is removed, Qt complains about it. But should definitely not crash.
So I guess to you this code works?
By the way, when segfaults output complains:
HEAP[temp.exe]:
HEAP: Free Heap block 52b3e88 modified at 52b3ee4 after it was freed
and stack-trace shows:
0 ntdll!DbgUiConnectToDbg C:\\WINDOWS\\system32\tdll.dll 0 1 ntdll!RtlpNtMakeTemporaryKey C:\\WINDOWS\\system32\tdll.dll 0
2 ntdll!LdrFindEntryForAddress C:\\WINDOWS\\system32\tdll.dll 0
3 ?? 0
4 ?? 0
5 ?? 0
6 ?? 0
mumble mumble...
Bookmarks