Home > other >  Questions about using database QSqlTableModel
Questions about using database QSqlTableModel

Time:11-25

I now use QSqlDatabase connected the oracle database, able to operate through the QSqlQuery associated SQL statement, but by QSqlTableModel, always can't remove the record from the database, the following code QSqlTableModel Model (0, db);//db is my QSqlDatabase Model. SetTable (" table_name ");//table_name is the name of the table in the database, the table permissions is absolutely yes, and many records in the table Model. The select (); If (Model. The rowCount () & gt; 0) {... The Model here. The rowCount () is 0, this is what reason is caused? Each ace to give directions!

CodePudding user response:

QSqlTableModel is and QTableView cooperate with, the constructor of the parent initialization parameters should be corresponding TableView

CodePudding user response:

You didn't select anything, can return to what seems to be a function setFilter ()

CodePudding user response:

Thank you for the above two answer, but I don't have to show it, should be no need to use QTableView, the default structure parameter parant is zero! As for setfilter, set up also not line, do not set setfilter, select the all records should be! Need via setfilter filtering, also hope you continue to top one, if I have a wrong place although points out, thank you!

CodePudding user response:

I use after their top again, in the select lastError get the error, prompt "QODBC3: unable to execute the statement" expert help analysis, thank you!

CodePudding user response:

Refer to the third floor hiti_tony published in the 2009-09-04 09:33: thank you for the above two answers, but I don't have to show it, should it is not necessary to use QTableView, the default structure parameter parant is zero! As for setfilter, set up also not line, do not set setfilter, select the all records should be! Need via setfilter filtering, also hope you continue to top one, if I have a wrong place although points out, thank you! Why not use QSQlQuery

CodePudding user response:

I have said on the subject, with QSQlQuery is feasible, but directly use the SQL statement is not convenient to insert the BLOB types of data, so I want to use QSqlTableModel give it a try,

CodePudding user response:

This post stop here, I change the query mode,

CodePudding user response:

reference 1st floor weixin_38060297 response:
QSqlTableModel is and QTableView cooperate with, the constructor of the parent initialization parameters should be corresponding TableView
like we don't have to table, dropping
  • Related