QSqlQuery does not return a record set?
-
wrote on 31 Mar 2024, 16:58 last edited by
Currently I process a QSqlQuery query row by row in a while(q.next()) loop. Is there no way of capturing the result of a query into a container, a result set...
-
@Christian-Ehrlicher How do I pass all records into a vector??
I want to do this:
std::vector<PasswordRecord> vec; QSqlQuery q; if(! q.exec(SQL::FindAllPassword)) { showError(q.lastError()); return vec; } while(q.next()) { PasswordRecord rec(q); vec.push_back(rec); } return vec;
How do i program PasswordRecord ?? There should be a way to get the result set of the QSqlQuery!! As in .NET!!
You get the sql record out of a query with... QSqlQuery::record(). If you want to store it into your own structure then you have to convert it by yourself.
-
Currently I process a QSqlQuery query row by row in a while(q.next()) loop. Is there no way of capturing the result of a query into a container, a result set...
@jdent what did you try and what do you want to do?
-
@jdent what did you try and what do you want to do?
wrote on 31 Mar 2024, 19:33 last edited by@Christian-Ehrlicher I want to do a FindAll() method that returns all rows of a table in a std::vector -- such a simple thing seems impossible in Qt...
-
@Christian-Ehrlicher I want to do a FindAll() method that returns all rows of a table in a std::vector -- such a simple thing seems impossible in Qt...
@jdent Then pass all records into a vector and search in them - what's the problem?
-
@jdent Then pass all records into a vector and search in them - what's the problem?
wrote on 31 Mar 2024, 19:59 last edited by jdent@Christian-Ehrlicher How do I pass all records into a vector??
I want to do this:
std::vector<PasswordRecord> vec; QSqlQuery q; if(! q.exec(SQL::FindAllPassword)) { showError(q.lastError()); return vec; } while(q.next()) { PasswordRecord rec(q); vec.push_back(rec); } return vec;
How do i program PasswordRecord ?? There should be a way to get the result set of the QSqlQuery!! As in .NET!!
-
@Christian-Ehrlicher How do I pass all records into a vector??
I want to do this:
std::vector<PasswordRecord> vec; QSqlQuery q; if(! q.exec(SQL::FindAllPassword)) { showError(q.lastError()); return vec; } while(q.next()) { PasswordRecord rec(q); vec.push_back(rec); } return vec;
How do i program PasswordRecord ?? There should be a way to get the result set of the QSqlQuery!! As in .NET!!
You get the sql record out of a query with... QSqlQuery::record(). If you want to store it into your own structure then you have to convert it by yourself.
-
You get the sql record out of a query with... QSqlQuery::record(). If you want to store it into your own structure then you have to convert it by yourself.
wrote on 31 Mar 2024, 20:43 last edited by@Christian-Ehrlicher Thanks!!
-
3/7