PDA

View Full Version : QTDS - SQLServer 2000 - Win strange behaviour



jpujolf
22nd January 2008, 17:19
I've had a problem. I presumed was my mistake, as usual ;). But after some investigation I think I've found a Qt-bug. Anybody can test this code in a Win-xx environment to confirm my suspects ?

Environment : mingw32 3.4.2, SQLServer 2000-SP4, Qt 4.3.0, driver QTDS



#include <QApplication>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlRecord>
#include <QVariant>
#include <fstream>

using namespace std;

int main(int argc, char *argv[])
{
ofstream DEBUG;
DEBUG.open ( "LOG.TXT" );

QCoreApplication app(argc, argv);

QSqlDatabase db = QSqlDatabase::addDatabase ( "QTDS" );
db.setHostName ( "<HOSTNAME>" );
db.setDatabaseName ( "<DATABASE>" );
db.setUserName ( "sa" );
db.setPassword ( "<pwd>" );
db.open();

QSqlQuery QRY ( db );
// here you MUST put a query that select at least a field longer than 255 chars
// ( 300 , 500 , 800, ... )
QString SEL = "SELECT FIELD_LONGER_THAN_255_CHAR FROM TABLE";

QRY.exec ( SEL );
QRY.last();
QRY.first();

while ( QRY.isValid() )
{
DEBUG << (const char *)QRY.record().value ( 0 ).toString().toAscii() << "\n";
QRY.next();
}

DEBUG.close();
return 0;
}


In windows, when the field is longer than 255 chars ( SQL analizer from Microsoft returs all the data ) the value returned from Qt's classes is "cutted" to 255 chars.

VERY Strange....

jpujolf
29th January 2008, 10:17
Hi all,

Nobody uses this combination ( mingw - SQLServer - Win32 ) ?? :crying:

I'm f...ed....