Hi.
I'll try:
We've a connection to the daytabase in memory:
db.setDatabaseName(":memory:");
if (!db.open()) {
return false;
}
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "connection1");
db.setDatabaseName(":memory:");
if (!db.open()) {
return false;
}
To copy to clipboard, switch view to plain text mode
The question is how to create a secod connection to the same database which is named ":memory:".
In the next thread we're doing :
db.setDatabaseName(":memory:");
if (!db.open()) {
return false;
}
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "connection2");
db.setDatabaseName(":memory:");
if (!db.open()) {
return false;
}
To copy to clipboard, switch view to plain text mode
The connection is opened but we're receiving the new instance of empty database.
If the database is working on file i.e.
in one thread
db.setDatabaseName("myFile.db");
on second
db.setDatabaseName("myFile.db");
the problem disapears and everything seams to be OK.
in one thread
db.setDatabaseName("myFile.db");
on second
db.setDatabaseName("myFile.db");
the problem disapears and everything seams to be OK.
To copy to clipboard, switch view to plain text mode
we've two paralel connections.
The question is how to acheive the same result in memory database. Is it possible?
Bookmarks