Hello.

Yes, one more boring thread about QODBC failing to work.

The problem is that this time is not a non-existing plugin, or an ABI issue, or a path spaguetti, or whatever else you might imagine. It might be an even sillier issue, who knows. Fact is that now I am at this kind of juncture where the idea of a flying laptop is starting not to seem a big drama.

So, let's get to the point. I am trying to connect to a given database from a devil-ish variety; not that I am happy with the idea, but there's really no option about that; so far so good:

Qt Code:
  1. QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
  2. db.setDatabaseName("DRIVER={SQLServer};SERVER=<server ip>;DATABASE=<db name>;UID=<user name>;PORT=1433;PWD=<nsa level password>;");
  3.  
  4. if( !db.isValid() )
  5. {
  6. qDebug() << "INVALID DATABASE!";
  7. }
  8. else
  9. {
  10. qDebug() << "Database is valid :)";
  11. }
  12.  
  13. qDebug() << "ODBC driver valid?" << db.isValid();
  14. if( !db.open() )
  15. {
  16. QString error;
  17. error = "SERVER Said: \"" + db.lastError().text();
  18.  
  19. qDebug() << error;
  20. for( int i=0; i<db.drivers().count(); i++ )
  21. {
  22. qDebug() << db.drivers().at(i);
  23. }
  24. }
To copy to clipboard, switch view to plain text mode 

This, outputs:

Qt Code:
  1. Database is valid :)
  2. ODBC driver valid? true
  3. "SERVER Said: "��������������������d
  4. "QSQLITE"
  5. "QSQLITE3"
  6. "QMYSQL3"
  7. "QMYSQL"
  8. "QODBC3"
  9. "QODBC"
To copy to clipboard, switch view to plain text mode 
Pretty standard stuff.

The most interesting part is where it says crap about ubuntu and whatnot (I'm in Gentoo, I really wonder where does that come from...). Anyway, the plugin is there, I have tried to force QT_PLUGINS_PATH and run from the command line, same problem. I tried ldd on the binary, and also in the individual libqt*.so files that are involved (gui and sql, mostly), all seem sane (and Gentoo tools would detect that kind of breackage). Anyway, I even tried to rebuild qtsql (I knew it wouldn't help, but still...).

I also tried copying the plugin folder to the build folder to no avail.

Finally, I let you know that I can perfectly connect using the same IP and credentials from my command line, with the tds/unixodbc combo. So, it's definitely not a problem in my server.

I am not new to qt neither to qtsql. I am no specialist, but I have found my way and built a small lot of applications during several years. Admittedly, I've been some months doing some other things, so, maybe it is something stupid I am missing here... At this point, after a couple days of frustration, I guess the best I can do is to close the lid and go for a gin, or a dozen.

Any help is welcome.

Thank you beforehand.