Skip to content
Advertisement

I’m trying to retrieve data from qSQL database

But it does not get the data from the database. I’m do not want to retrieve the data to the table and want to display data in particular line edit. What is the error? Is there any modification?

This is the Code that I’m using:

Advertisement

Answer

This code has four main issues:

  1. You have deleted the ui at the beginning of your code. Hence, the first line that calls ui-> will crash the program.
  2. You have defined your query improperly. Also, your way to select a name for your connection is not right.
  3. You have executed your query twice (one is enough).
  4. You’ve not bind values for username and password.

Please use the following:

Please add #include <QSqlError> to the top, if you have not already included this library.

Only to the questionary:

To show details in a new window, after you got the target user’s information from your database, you can create a new dialog (window) and show the results in it as follows:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement