SQLQUERY - column value retrun problem
Dear All
here is my code
The i value always retruning "0"
but the column value contains "1" also.
what mistake in the below code? why i return always zero?
Code:
{
int rowno = activeRow();
RowItems = iDBConnect->Selecting();
if(selectedRow == previousRow)
{
iFilterUpdate = new FilterUpdate();
iFilterUpdate->ui.lineEdit->setText(string1);
FilterNumb* item = RowItems[rowno];
iFilterUpdate->activeRow(item->id);
TInt i;
query.
exec(QString("select Enable from FilterNumTable where id = %1") .arg(item->id));
if (query.next())
{
i = query.value(2).toBool();
}
if(i)
{
iFilterUpdate->ui.CheckEnable->setCheckState(Qt::Checked);
}
else
{
iFilterUpdate->ui.CheckDisable->setCheckState(Qt::Checked);
}
this->close();
}
else
{
previousRow = selectedRow;
}
}
Re: SQLQUERY - column value retrun problem
toBool() returns a bool.
Use toInt()
Re: SQLQUERY - column value retrun problem
Quote:
Originally Posted by
tbscope
toBool() returns a bool.
Use toInt()
Dear tbscope,
thx for ur answer, i used toInt() also but same problem comming.
Re: SQLQUERY - column value retrun problem
Add these lines:
At the top of your code
Just above i = query.value(2).toBool();
Code:
qDebug() << "query value =" << query.value(2);
Then run it and look what the actual value is.
Re: SQLQUERY - column value retrun problem
Regardless if i is 0 or 1 you always set the state Qt::Checked! Use Qt::Unchecked for the else scope.
Re: SQLQUERY - column value retrun problem
Quote:
Originally Posted by
Lykurg
Regardless if i is 0 or 1 you always set the state Qt::Checked! Use Qt::Unchecked for the else scope.
The Qt::Checked state is being set on two different controls. If they are in a QButtonGroup then they might be automatically exclusive. This would usually be done with QRadioButton or a single QCheckBox though.
Re: SQLQUERY - column value retrun problem
Quote:
Originally Posted by
ChrisW67
The Qt::Checked state is being set on two different controls.
Ups, you are right, my eyes aren't absolutely open yet...
Re: SQLQUERY - column value retrun problem
Dear All,
issue is resolved , thx for all .