Hi thanks for your help and i have made some modifications in my code once please go through this and tell me where i am making mistake..?
Here is my code
//searchedit->setText(str1);
QString str
("SELECT * FROM details WHERE mobile=");
QString finalStr
= str
+ str1.
toAscii().
data();
qDebug()<<"Data in FinalStr:"<<finalStr;
bool ret;
//ret=query.exec("SELECT * FROM details WHERE mobile='str1.toAscii().data()'");
query.prepare("finalstr");
ret=query.exec();
if(ret==true)
{
qDebug("comparison success");
msgbox.setText("<h5>Registered User</h5>");
msgbox.exec();
}
else
{
msgbox.setText("Not Registered");
msgbox.exec();
}
* * * *
QString str1 = searchedit->text();
//searchedit->setText(str1);
QString str("SELECT * FROM details WHERE mobile=");
QString finalStr = str+ str1.toAscii().data();
qDebug()<<"Data in FinalStr:"<<finalStr;
bool ret;
QSqlQuery query;
//ret=query.exec("SELECT * FROM details WHERE mobile='str1.toAscii().data()'");
query.prepare("finalstr");
ret=query.exec();
if(ret==true)
{
qDebug("comparison success");
QMessageBox msgbox;
msgbox.setText("<h5>Registered User</h5>");
msgbox.exec();
}
else
{
QMessageBox msgbox;
msgbox.setText("Not Registered");
msgbox.exec();
}
* * * *
To copy to clipboard, switch view to plain text mode
This code producing a result as Not Registered even if the data is present in the database
Please help me
Thanks in advance
Rohith.G
Bookmarks