QT with ODBC Driver cant connect to MSSQL



  • I have developed part of a database manager in QT and it all works fine, i can read tables and show its data, remove rows etc.
    BUT now i try to continue developing this program on a different computer it all breaks down. I can compile the project just fine, there is no errors, however when i run it and try to connect to the database the program feezes for a about 20seconds(im guessing its trying to connect for a while) then it comes back to life and was unable to connect. The message i get from QSqlDatabase::lastError() is: "[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). QODBC3: Unable to connect"

    I am sure that the server exists and that i have access because i can use the MSSQL management studio to connect without problems. On the new computer i have compiled the ODBC driver from the same QT source as on the first and i can see that the QODBC driver is available.

    I'm all out of ideas on this and i would love some help.



  • Example of SQL Server Conection :

    @
    QString ipserver,LoginName,database,Pass;
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MyDatabase");

    db.setDatabaseName("DRIVER={SQL Server};Server="+ipserver+";Database="+database+";Uid="+LoginName+";Port=1433;Pwd="+Pass+";WSID=");

    if(db.open())
    {
    qDebug() << "Opened";
    db.close();
    }
    else
    qDebug() << "Error" << db.lastError().text();@

    the WSID =. “is used to hide the client machine to the database server log ,is optional .


Log in to reply
 

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