hi , I've written a SQL query based on QT assisstant and it says that you can use the prepare() method instead of exec() then you can pass your parameter by the help of two methods called : bindvalue() and addbindvalue() here is an snippet code of my problem :
Query->prepare("SELECT ID , Row , Col FROM sometable WHERE Row = :row AND Col = :col");
Query->bindValue(":row" , __Row);
Query->bindValue(":col" ,__Col);
Query->exec();
qDebug("%s" , Query->executedQuery().toStdString().c_str());
output :
SELECT ID , Row , Col FROM sometable WHERE Row = ? AND Col = ?
and also I've use another suggested way :
Query->prepare("SELECT ID , Row , Col FROM sometable WHERE Row = :row AND Col = :col");
Query->addBindValue(0 , __Row);
Query->addBindValue(1 ,__Col);
Query->exec();
qDebug("%s" , Query->executedQuery().toStdString().c_str());
output :
SELECT ID , Row , Col FROM sometable WHERE Row = ? AND Col = ?
but when I use exec() normally it works perfectly and will replace the corresponding values instead of "?".
is there any explanation about that? or should I use the ordinary exec()?
regards.