Results 1 to 11 of 11

Thread: cannot open include file qsqldatabase

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Apr 2012
    Location
    Romania
    Posts
    22
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: cannot open include file qsqldatabase

    Quote Originally Posted by ChrisW67 View Post
    Yes, run qmake after changing the PRO file.
    Thanks. It works.

    Quote Originally Posted by ChrisW67 View Post
    Your "quite simple" code is also unlikely to work when it compiles. A MySQL Workbench file is not a MySQL database.
    Thanks. I'm a little new in working with Qt and MySQL. I'll work with the console to create my database. Is there a way to find out in which file the database created is saved?


    Added after 9 minutes:


    Quote Originally Posted by toufic.dbouk View Post

    just a note, dont you need a connection string or a dsn to open the connection with a database ?
    something like :
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    2. QString servername = "X-PC\\LOCALHOST";
    3. QString dbname = "CARSQL";
    4. QString connTemplate = "DRIVER={SQL SERVER};SERVER=%1;DATABASE=%2;";
    5. QString connectionString = connTemplate.arg(servername).arg(dbname);
    6. db.setDatabaseName(connectionString);
    To copy to clipboard, switch view to plain text mode 

    or

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    2. db.setHostName("acidalia");
    3. db.setDatabaseName("customdb");
    4. db.setUserName("mojito");
    5. db.setPassword("J0a1m8");
    To copy to clipboard, switch view to plain text mode 
    Well I'm working on localhost and with no password or specific user name. I thought qt will implicit put localhost, root and no password. I have another question: How do you specify to which file the app should connect?
    Last edited by Saurian; 23rd September 2013 at 07:56.

Similar Threads

  1. Replies: 1
    Last Post: 23rd May 2011, 04:53
  2. Replies: 3
    Last Post: 1st November 2010, 16:33
  3. Replies: 4
    Last Post: 9th May 2010, 16:18
  4. Replies: 2
    Last Post: 9th March 2010, 05:21
  5. Replies: 10
    Last Post: 15th June 2009, 19:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.