Reputation: 318
i have made a database in terminal by this command:
sqlite3 test.db
then i tried to make a table by using these codes:
ui->setupUi(this);
db1.setDatabaseName("test.db");
bool k=db1.open();
QSqlQuery q(db1);
q.prepare("CREATE TABLE by_code(id INT)");
q.exec();
qDebug()<<"isOpen: "<<k<<" Error:"<<q.lastError();
the output is :
isOpen: true Error: QSqlError(-1, "Unable to fetch row", "No query")
whats problem and how can i solve it?
Upvotes: 0
Views: 299
Reputation: 180010
Qt tried to get the result of the query, but a CREATE TABLE
statement does not return a result.
This is not considered an actual error.
To check whether the query succeeded, check the return value of the exec
function.
Upvotes: 5