Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QSqlError(-1, "Driver not loaded", "Driver not loaded")

QSqlError(-1, "Driver not loaded", "Driver not loaded")

Scheduled Pinned Locked Moved Installation and Deployment
1 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dndeed
    wrote on last edited by
    #1

    Hi,

    I am trying to connect to a sql database for the first time and I'm having some trouble. I don't know much about sql or qt, so I've been adapting my code from someone who worked on this project before me in visual studio. I cannot seem to over my database, and I think its because I'm not using the correct driver. Here's my code:

    qDebug()<<QSqlDatabase::drivers();

    QSqlDatabase db;
    db.addDatabase("QODBC3");
    db.setHostName("localhost");
    db.setDatabaseName("databaseName");
    db.setUserName("name");
    db.setPassword("pa$$");

    bool ok = db.open();
    if (ok == false) qDebug() << db.lastError();

    The first debug statement returns all valid drivers ("QSQLITE", "QODBC", "QODBC3") but none of those do anything, i still get the driver not loaded error when I try to open the database.

    One last thing, I got most of my data (username, password, ect) from the code I've been copying, but that code uses driver = get_driver_instance(); which is totally unknown to me.

    Thanks in advance for any help,

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved