Qt development, using ODBC interface, query mysql, appear qsqlquery:: Value: not positioned on a valid record
Question: in the library management system developed by QT craetor integrated development environment, the newly created database class is used to operate the database. It inherits from QObject and uses the interface provided by ODBC to connect with the database. The database is mysql5.7, When using the following query statement, we report an error:
error information: qsqlquery:: Value: not positioned on a valid record
we query the relevant information:
the solutions we have found
try according to the solutions provided in the article, the problems still exist.
Later, some information was printed in various locations, and it was found that qdebug & lt& lt; condition<& lt; content<& lt;“ The variables condition and content in “on” can be printed normally, but “on” printed out is “?”
when I thought of creating a window before, the window title set in Chinese would be garbled. The solution I found at that time was to add the following code to the. Cpp file of the corresponding class:
?Pragma execution_ character_ set("utf-8")
Solution:
add the code block as shown above to the database.cpp file:
edit test information:
test output successful:
end! Scatter flowers! Record it!
Read More:
- Talking about the errors encountered in installing MySQL ODBC (error 1918)
- QT learning 3: configuration and testing of QT creator 2.4.1 development environment
- MySQL error — multiple methods of failed to find valid data directory and MySQL setting password appear
- MySQL Workbench: Error Code: 2013. Lost connection to MySQL server during query solution
- MySQL startup problem (ERROR 1045 (28000): Access denied for user’ODBC’@’localhost’ (using password: NO))
- Vtk8.0 compilation process record under vs2017 and qt5.12.1
- “No nodes available to run query” is reported when using Presto to connect to MySQL query“
- Error in ODBC connection of Dameng database, [ISQL] error: could not SQLConnect
- QT interface refresh crash, exception
- Visionox shows app development record
- Record the problems encountered when VTK is used with QT
- A convenient method to count the total number of query results in MySQL
- QT encountered in CentOS installation( qt.qpa.plugin : Could not load the Qt platform plugin “xcb” )
- Solutions to UCenter Info: MySQL query error app1
- Common errors and solutions of Qt development application under Ubuntu
- QT + MySQL generates an EXE file and reports an error “driver not loaded”. Solution steps
- 【Exception】mysqldump: Error 2013: Lost connection to MySQL server during query when dumping table…
- Centos-7 set boot to enter the text interface (not enter the graphical interface)
- MySQL driver compiling method of QT under windows and solutions to abnormal errors
- WSL start QT error qt.qpa.xcb : could not connect to display :0.0