I am quite confused what is going on here and I have to be completely missing something stupid, but...
mydb.open();
query.prepare("select * from inventory");
query.exec();
mydb.open();
QSqlQuery query;
query.prepare("select * from inventory");
query.exec();
To copy to clipboard, switch view to plain text mode
A simple query to my database that works in numerous other places, just does not function at all in one of my pushbutton slots.
0x14bfed30 //Query Result
" " //Query Error
0x14bfed30 //Query Result
" " //Query Error
To copy to clipboard, switch view to plain text mode
val = ui->listView->model()->data(index).toString();
mydb.open();
query.prepare("select * from inventory where item ='"+val+"'");
if(query.exec())
{
while(query.next())
{
ui->lineEdit_shelf->setText(query.value(1).toString());
ui->lineEdit_container->setText(query.value(2).toString());
ui->lineEdit_finished->setText(query.value(4).toString());
ui->lineEdit_unfinished->setText(query.value(5).toString());
ui->textEdit_notes->setText(query.value(6).toString());
if(query.value(3) == 1)
ui->checkBox->setChecked(true);
else
ui->checkBox->setChecked(false);
}
mydb.close();
}
else
qDebug() << query.lastError().text();
}
val = ui->listView->model()->data(index).toString();
mydb.open();
QSqlQuery query;
query.prepare("select * from inventory where item ='"+val+"'");
if(query.exec())
{
while(query.next())
{
ui->lineEdit_shelf->setText(query.value(1).toString());
ui->lineEdit_container->setText(query.value(2).toString());
ui->lineEdit_finished->setText(query.value(4).toString());
ui->lineEdit_unfinished->setText(query.value(5).toString());
ui->textEdit_notes->setText(query.value(6).toString());
if(query.value(3) == 1)
ui->checkBox->setChecked(true);
else
ui->checkBox->setChecked(false);
}
mydb.close();
}
else
qDebug() << query.lastError().text();
}
To copy to clipboard, switch view to plain text mode
Example of setup in a listView_clicked slot. But it functions perfectly well. Any kind of guidance would be greatly appreciated, as this problem popped up while I was attempting to make an update query, and it seems to be a much bigger issue.
Bookmarks