db = QSqlDatabase::addDatabase("QODBC");#ifdef WIN32 db.setDatabaseName("DRIVER={SQL Server};Server=10.10.1.1;DATABASE=Obmen");#else db.setDatabaseName("DRIVER={FreeTDS};Server=10.10.1.1;DATABASE=Obmen");#endif db.setUserName("***"); db.setPassword("***"); if(!db.isValid()) qDebug()<< "ODBC driver don't loaded."; db.open(); if(db.isOpenError()) qDebug()<<db.lastError().text();
[global]connect timeout = 10#debug flags = 0xffff#dump file = /tmp/freetds.logtext size = 64512timeout = 10[LIMSServer]host = 192.168.0.177tds version = 8.0clientcharset = UTF-8
[LIMSDatabase];Database = CL_CO_ANDINADatabase = OLDEMODriver = FreeTDSPort = 1433Servername = LIMSServer
[FreeTDS]Description = TDS DriverDriver = /usr/lib/x86_64-linux-gnu/freetds/lib/libtdsodbc.soSetup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.soCPTimeout =CPReuse =
bool QWshDatabase::openDatabase(const QString &username, const QString &password, const QString &timeout){ if (_db.isOpen() == false) { _db.setDatabaseName("LIMSDatabase"); _db.setUserName(username); _db.setPassword(password); if (timeout.isEmpty() == true) _db.setConnectOptions("SQL_ATTR_CONNECTION_TIMEOUT=3"); else _db.setConnectOptions(QString("SQL_ATTR_CONNECTION_TIMEOUT=%Timeout%").replace("%Timeout%", QString::number(timeout.toInt() / 3))); emit connecting(); if (_db.open() == false) { setProperty("LastError", _db.lastError().text()); return false; } } return true;}