Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6254433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:10:43+00:00 2026-05-24T14:10:43+00:00

Now I’m working on Qt project and I need some MySQL support. MySQL was

  • 0

Now I’m working on Qt project and I need some MySQL support. MySQL was installed on virtual machine (Virtual Box) on Ubuntu Server. Here’s what I do:

int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    QSqlDatabase hospital_db = QSqlDatabase::addDatabase("QMYSQL");
    hospital_db.setHostName("192.168.56.10");
    hospital_db.setDatabaseName("hospital_db");
    hospital_db.setUserName("usr1");
    hospital_db.setPassword("123");
    if(!hospital_db.open()) {
        qDebug() << "\nFailed connect to MySQL";
    };

    QTableView *tView = new QTableView;
    QSqlTableModel model;

    model.setTable("my_table");
    model.setEditStrategy(QSqlTableModel::OnManualSubmit);
    if (!model.select()) {
         QMessageBox msgBox;
         QString err(model.lastError().text());
         msgBox.setText(err);
         msgBox.exec();
    }
    model.setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    model.setHeaderData(1, Qt::Horizontal, QObject::tr("Name"));
    model.setHeaderData(2, Qt::Horizontal, QObject::tr("Address"));
    model.setHeaderData(3, Qt::Horizontal, QObject::tr("Phone"));

    tView->setModel(&model);
    tView->show();

    QSqlDatabase::removeDatabase("my_table");
    return app.exec();
}

I get “Unable to find table my_table” error . Table my_table is created properly. Here is result of SHOW FIELDS OF my_table:

+----------------+-----------+------+-----+---------+----------------+
| Field          | Type      | Null | Key | Default | Extra          |
+----------------+-----------+------+-----+---------+----------------+
| hosp_id        | int(11)   | NO   | PRI | NULL    | auto_increment |
| hosp_name      | char(100) | NO   |     | NULL    |                |
| hosp_address   | char(100) | NO   |     | NULL    |                |
| hosp_ph_number | char(8)   | NO   |     | NULL    |                |
+----------------+-----------+------+-----+---------+----------------+

And finally here is general_log from MySQL:

| 2011-08-11 12:21:54 | usr1[usr1] @  [192.168.56.1] |        36 |         0 | Connect      | usr1@192.168.56.1 on hospital_db    |
| 2011-08-11 12:21:54 | usr1[usr1] @  [192.168.56.1] |        36 |         0 | Init DB      | hospital_db                         |
| 2011-08-11 12:21:54 | usr1[usr1] @  [192.168.56.1] |        36 |         0 | Query        | SET NAMES utf8                      |
| 2011-08-11 12:21:54 | usr1[usr1] @  [192.168.56.1] |        36 |         0 | Field List   | my_table                            |
| 2011-08-11 12:21:54 | usr1[usr1] @  [192.168.56.1] |        36 |         0 | Field List   | my_table                            |
| 2011-08-11 12:21:54 | usr1[usr1] @  [192.168.56.1] |        36 |         0 | Query        | show index from my_table                |
| 2011-08-11 12:22:01 | usr1[usr1] @  [192.168.56.1] |        36 |         0 | Quit         |                                     |

So, What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:10:44+00:00Added an answer on May 24, 2026 at 2:10 pm

    Well, seems that I had some problems with permissions on server side. Now everything is fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

now i'm working on a project for creating audio unit instrument that provide the
Now that I'm working in F#, is it time to start writing up some
now i need to insert some data from the sqlserver into a word,i know
Now I am implementing UDP server to gather sflow datagrams using netty library. Here
Now I'm trying some tests to erase the actual touch to beam in NFC
Now here is another problem.. my code: <script type=text/javascript> function validate_form () { if
Now i face a problem in my porting job, when i need to implement
Now this is a weird one We have a project where we are reading
Now I know that I am at risk here of asking a duplicate question,
Now a days in several of my iOS applications I need to get adjacent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.