Reputation: 179
I wrote a SQLite database for client server program. but during debug when it comes to line which I star in code it crash and stop debuging. Could you please help me ?thanks
Here is the code:
bool create = !QFile::exists("Message.dat");
if (!myserver.createConnection())
return 1;
if (create) ***"Here return false"****
myserver.insertMessage();
void insertMessage(QString IPAddrress, QDate date, QString message)
{
QSqlQuery query;
query.addBindValue(IPAddrress);
query.addBindValue(date);
query.addBindValue(message);
query.exec();
}
void MainWindow::insertMessage()
{
QSqlQuery query;
query.prepare("INSERT INTO messages(IPAddress, date, message)"
" values(?,?,?)");
}
Upvotes: 0
Views: 67
Reputation: 1040
Please take a look at this line:
bool create = !QFile::exists("Message.dat");
The way your syntax is written, it says create is true if "Message.dat" does not exist
, because you have a !
in front of the exists
function. This will return false
if "Message.dat"
does exist. Try removing the !
operator.
Upvotes: 1