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:
db.setDatabaseName("DRIVER={SQLServer};SERVER=<server ip>;DATABASE=<db name>;UID=<user name>;PORT=1433;PWD=<nsa level password>;");
if( !db.isValid() )
{
qDebug() << "INVALID DATABASE!";
}
else
{
qDebug() << "Database is valid :)";
}
qDebug() << "ODBC driver valid?" << db.isValid();
if( !db.open() )
{
error = "SERVER Said: \"" + db.lastError().text();
qDebug() << error;
for( int i=0; i<db.drivers().count(); i++ )
{
qDebug() << db.drivers().at(i);
}
}
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DRIVER={SQLServer};SERVER=<server ip>;DATABASE=<db name>;UID=<user name>;PORT=1433;PWD=<nsa level password>;");
if( !db.isValid() )
{
qDebug() << "INVALID DATABASE!";
}
else
{
qDebug() << "Database is valid :)";
}
qDebug() << "ODBC driver valid?" << db.isValid();
if( !db.open() )
{
QString error;
error = "SERVER Said: \"" + db.lastError().text();
qDebug() << error;
for( int i=0; i<db.drivers().count(); i++ )
{
qDebug() << db.drivers().at(i);
}
}
To copy to clipboard, switch view to plain text mode
This, outputs:
Database is valid :)
ODBC driver valid? true
"SERVER Said: "��������ï€ï“€ï…€ï”€ïƒ€ï¿½ï¿½ï¿½ï¿½ï€ï¿½ï¿½ï¿½ï¿½ïŽ€ïƒ€ï…€ï”€ï“€ïƒ€ïˆ€ï„€ï¿½ï¿½ï¿½ï¿½ï€ï‚€ï…€ï„€d
"QSQLITE"
"QSQLITE3"
"QMYSQL3"
"QMYSQL"
"QODBC3"
"QODBC"
Database is valid :)
ODBC driver valid? true
"SERVER Said: "��������ï€ï“€ï…€ï”€ïƒ€ï¿½ï¿½ï¿½ï¿½ï€ï¿½ï¿½ï¿½ï¿½ïŽ€ïƒ€ï…€ï”€ï“€ïƒ€ïˆ€ï„€ï¿½ï¿½ï¿½ï¿½ï€ï‚€ï…€ï„€d
"QSQLITE"
"QSQLITE3"
"QMYSQL3"
"QMYSQL"
"QODBC3"
"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.
Bookmarks