SOLVED: Using MS SQL Server 2013 Database with QT



  • Hallo, I'm trying to connect my MS SQL Server Database to my QT Projekt. This is my code:
    @#include <QCoreApplication>
    #include <QtSql/QtSql>
    #include <QDebug>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    db.setHostName("(localdb)\\Projects");
    db.setDatabaseName("PDB");
    db.setUserName("DOMAIN\\user");
    db.setPassword("");
    
    if (!db.open()) {
       qDebug() << db.lastError().text();
       return 1;
    }
    
    
    if (!db.open()) {
       qDebug() << db.lastError().text();
       return 1;
    }
    
    
    return a.exec(&#41;;
    

    } @

    But im allways getting this error:
    Microsoft ODBC Driver Manager / The Datasourcename could not be found, and there was no standard driver selected QODBC3: Unable to connect

    I have created the Database with Visual Studio 2013.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.