검색결과 리스트
qt #qsqlquery에 해당되는 글 1건
- 2020.09.23 QSqlQuery Select 결과 처리 관련
관련 문서 doc.qt.io/qt-5.14/qsqlquery.html#last
QSqlQuery Class | Qt SQL 5.14.2
QSqlQuery Class The QSqlQuery class provides a means of executing and manipulating SQL statements. More... Header: #include qmake: QT += sql Public Types Public Functions Detailed Description QSqlQuery encapsulates the functionality involved in creating, n
doc.qt.io
QSQlQuery는 결과를 return하면 해당 결과는 테이블 형태로 반환하게 된다.
간단하게 select해서 count를 보려면 다음과 같이 처리한다.
| QSqlQuery fileQuery(LocalDB); |
| QString queryString = QString("SELECT count(*) FROM file_export where cid = %1 and ccid = %2 and programid = %3") |
| .arg(caseID).arg(caseItemID).arg(static_cast<int>(enumValue)); |
| if (fileQuery.exec(queryString) == false) |
| return metaDataString; |
| int numberOfRows = 0; |
| if (fileQuery.next()) {//한번은 next를 해줘야 1번째 결과 행으로 이동한다. |
| numberOfRows = fileQuery.value(0).toInt(); |
| } |
| else { |
| return metaDataString; |
| } |
이 쿼리를 db 프로그램에서 select하면 다음과 같이 나오고 0번째가 그 값이 되기 때문이다.

RECENT COMMENT