Please, test this simple code :

Qt Code:
  1. #include <QApplication>
  2. #include <QtSql/QSqlDatabase>
  3. #include <QtSql/QSqlQuery>
  4. #include <QVariant>
  5. #include <fstream>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. int main(int argc, char *argv[])
  11. {
  12. ofstream DEBUG;
  13. DEBUG.open ( "LOG.TXT" );
  14.  
  15. QCoreApplication app(argc, argv);
  16.  
  17. QSqlDatabase db = QSqlDatabase::addDatabase ( "QODBC" );
  18. db.setHostName ( "HOSTNAME" );
  19. db.setDatabaseName ( "DRIVER=TDS;DSN=NAME;UID=sa;DATABASE=DB" );
  20. db.setUserName ( "sa" );
  21. db.setPassword ( "xxxxxx" );
  22. db.open ();
  23.  
  24. QSqlQuery QRY ( db );
  25. QRY.setForwardOnly(true);
  26. QRY.exec ( "SELECT 'TEST VALUE'" );
  27. QRY.next();
  28.  
  29. while ( QRY.isValid() )
  30. {
  31. DEBUG << "[" << (const char *)QRY.value ( 0 ).toString().toAscii() << "]\n";
  32. QRY.next();
  33. }
  34.  
  35. DEBUG.close();
  36.  
  37. return 0;
  38. }
To copy to clipboard, switch view to plain text mode 

It generates a correct SQL, that I can launch from inside isql, returning "TEST VALUE".

But when I run this small piece of code, the console shows a mystical "qGetStringData: Error while fetching data (-1)" and returns a NULL string. You can change the Query by any one you want, but if it returns an string it fails to receive the data...

I'm using Qt 4.3.4 on a Linux machine, Ubuntu 7.10 against al SQL Server living inside a W2K3 Server, unixODBC ans FreeTDS as TDS driver.

I know FreeTDS is not directly supported by Qt, but I think the problem is not inside FreeTDS, because isql works !!

Any clue ? It's an old question and is solved ? I've been surfing the web and I've found the problem but not clues nor solutions anywere

Thanks,

Jordi.