T
T
theSever2018-03-11 02:25:01
Qt
theSever, 2018-03-11 02:25:01

Qt C++ how to properly close sqlite db connection?

I write software that can work with different databases.
How to properly close the connection with an already connected database when choosing another one through the file dialog?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ighor July, 2018-03-11
@IGHOR

{
QSqlDatabase m_dataBase=QSqlDatabase::addDatabase("QSQLITE", "Con434");
m_dataBase.open();
...
m_dataBase.close();
}
QSqlDatabase::removeDatabase("Con434");

Con434 - an arbitrary name, you need to have a different one if you have several connections to the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question