Re: How to Retrive data...?
Your code has incorrect C++ syntax. QSqlQuery docs contains an example how to build a query with parameters using QSqlQuery::prepare().
Re: How to Retrive data...?
Sorry can you please elaborate the explanation i have not got anything which is familiar to my question in the QSqlQuery
Re: How to Retrive data...?
Click the second link in my post, read the docs and evaluate the code in the big gray box.
Re: How to Retrive data...?
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
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();
}
* * * *
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
Re: How to Retrive data...?
Quote:
Originally Posted by
gunturrohith
Code:
query.prepare("finalstr");
I don't think this is a valid SQL query. Do you know what is a string in c++ and how does it differ from a variable identifier?