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(?,?,?)");
}
queryobjects are somehow the same object (because you prepare it in one function, and bind values in another). They are not, they are two separate objects. Also, try explicitly giving the database to the query, just to be sure it really uses the same database. And check return value of every method, which may return an error.