hi to all, I've Centos7.5 as client and centos6.10 as mysql server. i am building small project and here i want to get maximum value from billno ( bill number ). I've tried this code :-
int Sales::setmaxno()
{
QString sql
= "select max(billno) from tableSale";
query->prepare(sql);
if(query->exec() )
{
if(qury.next())
{
Sales::maxno = query->value(0).toInt();
return Sales::maxno;
}
}
else
{
QMessageBox::information(this,
"Sales",
"in else " + query
->lastError
().
text() );
}
}
int Sales::setmaxno()
{
QSqlQuery qury;
QString sql= "select max(billno) from tableSale";
query->prepare(sql);
if(query->exec() )
{
if(qury.next())
{
Sales::maxno = query->value(0).toInt();
return Sales::maxno;
}
}
else
{
QMessageBox::information(this, "Sales", "in else " + query->lastError().text() );
}
}
To copy to clipboard, switch view to plain text mode
but this shows maxno = 0; always.
i think query "select max(billno) from tableSale"; is not selecting max of column.
how to get solved this problem.
Bookmarks