PDA

View Full Version : QSqlQuery::exec: database not open



ann93
6th March 2018, 10:37
Hi,

I am trying to have multiple QSqlDatabase connection.

I had set QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL","db") but QT says "QSqlQuery::exec: database not open".
But when I make it as QSqlDatabase::addDatabase("QPSQL"), the programs works well but I unable to have multiple connection and the program will crash.

Is there any way to do so? Thanks in advance

Added after 40 minutes:

Problem Solved. Did not call QSqlDatabase at setQuery.
setQuery(sqlCommand,*db);

Lesiok
6th March 2018, 10:39
Show the real code.