I have a sqlite 3 database where I have some fake data just for testing, but it seems that every time I try to do a simple query it gives me the error that I mentioned in the title.
here's the code:
db.setDatabaseName("adtDB.sql");
db.open();
if(db.isOpen())
{
if(q.exec())
{
qDebug()<<"works!";
while(q.next())
{
qDebug()<<q.value(8).toString();
}
}
qDebug()<<"---db failed to open! , error: "<<q.lastError().text();
db.close();
return true;
}
qDebug()<<"db failed to open! , error: "<<db.lastError().text();
return false;
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("adtDB.sql");
db.open();
if(db.isOpen())
{
QSqlQuery q = db.exec("SELECT * FROM adt");
if(q.exec())
{
qDebug()<<"works!";
while(q.next())
{
qDebug()<<q.value(8).toString();
}
}
qDebug()<<"---db failed to open! , error: "<<q.lastError().text();
db.close();
return true;
}
qDebug()<<"db failed to open! , error: "<<db.lastError().text();
return false;
To copy to clipboard, switch view to plain text mode
The database opens fine but this is the error that I get including the debug statement:
---db failed to open! , error: "No query Unable to fetch row"
the red text is the error the rest is in the debug statement that I included.
Bookmarks