| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 5 | |
Hello,
i am having a problem with qsqlquery in linux, i have tested in windows and it works ok, i am using qt
4.3.1, tested on gentoo and debian both, the odbc drivers i am using and the dsn are ok because it works
well with isql unixodbc commandline making queries, the parameters to QSqlDatabase are ok, if i change
anything (fail in password or ip) i get an messagebox with the error, the connection is open and ok, the
sql query is correct, works in windows and in isql command line in linux, the test compile without
problem but i get when i launch the test it fails, this is that i get:
skuda@skuda ~/temporal/pruebaodbc $ ./pruebaodbc
1
0
QSqlQuery::value: not positioned on a valid record
and this is the code of the test:
------------------------------------------------------------------------------------------------------------------------
#include <QApplication>
#include <QtGui>
#include <QtSql>
#include <iostream>
bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("DATABASE");
db.setUserName("FAKEUSER");
db.setPassword("FAKEPASSWORD");
if (!db.open()) {
QMessageBox::critical(0, QObject::tr("Database Error"),
db.lastError().text());
return false;
}
return true;
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
std::cout << createConnection() << std::endl;
QSqlQuery query;
query.exec("SELECT * FROM DATOS_ANTIGUOS.NOMBRE_COMUN");
std::cout << query.next() << std::endl;
std::cout << qPrintable(query.value(0).toString()) << std::endl;
return app.exec();
}
------------------------------------------------------------------------------------------------------------------------
--
[ signature omitted ]
Linos wrote: > Hello, > i am having a problem with qsqlquery in linux, i have tested in windows and it works ok, i am using qt > 4.3.1, tested on gentoo and debian both, the odbc drivers i am using and the dsn are ok because it works > well with isql unixodbc commandline making queries, the parameters to QSqlDatabase are ok, if i change > anything (fail in password or ip) i get an messagebox with the error, the connection is open and ok, the > sql query is correct, works in windows and in isql command line in linux, the test compile without > problem but i get when i launch the test it fails, this is that i get: > [...] Hi, This is most likely because the ODBC driver manager or driver you're using don't support unicode. For instance your program fails when using unixODBC/FreeTDS to connect to a Microsoft SQL Server, but succeeds when using unixODBC/MySQL to connect to a MySql server. Also, the FreeTDS driver doesn't support scrollable cursors so if you're using this driver all queries must be executed in forwardOnly mode. Try building QODBC with Q_ODBC_VERSION_2 defined and see what happens. You can also try experimenting with a different ODBC driver. -- [ signature omitted ]
I have tested compiling QT with Q_ODBC_VERSION_2 defined but i have the same problem, anyway the driver i am using support unicode, i am using maxdb odbc driver unicode (libsqlodw.so) i have tested the non-unicode version (libsqlod.so) but i get the same result, i am using the same qt version in windows with maxdb odbc unicode driver for windows without problem and using unicode characters with it, any other test i can do to find the problem? Thanks. Best Regards, Miguel Angel. Anders Larsen escribió: > Linos wrote: >> Hello, >> i am having a problem with qsqlquery in linux, i have tested in >> windows and it works ok, i am using qt >> 4.3.1, tested on gentoo and debian both, the odbc drivers i am using >> and the dsn are ok because it works >> well with isql unixodbc commandline making queries, the parameters to >> QSqlDatabase are ok, if i change >> anything (fail in password or ip) i get an messagebox with the error, >> the connection is open and ok, the >> sql query is correct, works in windows and in isql command line in >> linux, the test compile without >> problem but i get when i launch the test it fails, this is that i get: >> > [...] > > > Hi, > > This is most likely because the ODBC driver manager or driver you're > using don't support unicode. For instance your program fails when using > unixODBC/FreeTDS to connect to a Microsoft SQL Server, but succeeds when > using unixODBC/MySQL to connect to a MySql server. > > Also, the FreeTDS driver doesn't support scrollable cursors so if you're > using this driver all queries must be executed in forwardOnly mode. > > Try building QODBC with Q_ODBC_VERSION_2 defined and see what happens. > You can also try experimenting with a different ODBC driver. > > > -- > Anders L. > > -- > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with > "unsubscribe" in the subject or the body. > List archive and information: http://lists.trolltech.com/qt-interest/ > -- [ signature omitted ]
I have made more tests, i have tried installing the maxdb server in Linux insted of windows (client problem has been ever linux, in windows works ok), i have the same result, later i have installed ingres 2006 release 3 and i have the same result, i can do sql commands with isql commandline and connect with or without dsn from qt but when i try to do a valid query (tested in isql commandline) it returns false, obviously qt 4.3.1 seems to have any problems with any odbc drivers (almost my installation), anyone can say me how i could do a more meaningful log or anything else to help with that? Thanks in advance. Regards, Miguel Angel. Anders Larsen escribió: > Linos wrote: >> Hello, >> i am having a problem with qsqlquery in linux, i have tested in >> windows and it works ok, i am using qt >> 4.3.1, tested on gentoo and debian both, the odbc drivers i am using >> and the dsn are ok because it works >> well with isql unixodbc commandline making queries, the parameters to >> QSqlDatabase are ok, if i change >> anything (fail in password or ip) i get an messagebox with the error, >> the connection is open and ok, the >> sql query is correct, works in windows and in isql command line in >> linux, the test compile without >> problem but i get when i launch the test it fails, this is that i get: >> > [...] > > > Hi, > > This is most likely because the ODBC driver manager or driver you're > using don't support unicode. For instance your program fails when using > unixODBC/FreeTDS to connect to a Microsoft SQL Server, but succeeds when > using unixODBC/MySQL to connect to a MySql server. > > Also, the FreeTDS driver doesn't support scrollable cursors so if you're > using this driver all queries must be executed in forwardOnly mode. > > Try building QODBC with Q_ODBC_VERSION_2 defined and see what happens. > You can also try experimenting with a different ODBC driver. > > > -- > Anders L. > > -- > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with > "unsubscribe" in the subject or the body. > List archive and information: http://lists.trolltech.com/qt-interest/ > -- [ signature omitted ]
Linos wrote: [...] > anyone can say me how i could do a more meaningful log or anything else to help with that? Make sure that odbcinst.ini contains: [ODBC] Trace = yes TraceFile = /tmp/odbc.log -- [ signature omitted ]
I have saved the logs from the two odbc drivers i am testing (maxdb and ingres), they are compressed in this bzip file, they seems be failing in SQLFetchScroll. Anders Larsen escribió: > Linos wrote: > > [...] >> anyone can say me how i could do a more meaningful log or anything >> else to help with that? > > Make sure that odbcinst.ini contains: > > [ODBC] > Trace = yes > TraceFile = /tmp/odbc.log > > > -- > Anders L. > > -- > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with > "unsubscribe" in the subject or the body. > List archive and information: http://lists.trolltech.com/qt-interest/ >
Attachment:
Attachment:
odbclogs.tar.bz2
Description: application/bzip
Message 7 in thread
Linos wrote:
> I have saved the logs from the two odbc drivers i am testing (maxdb and ingres), they are compressed in
> this bzip file, they seems be failing in SQLFetchScroll.
>
> Anders Larsen escribió:
>> Linos wrote:
>>
>> [...]
>>> anyone can say me how i could do a more meaningful log or anything
>>> else to help with that?
>> Make sure that odbcinst.ini contains:
>>
>> [ODBC]
>> Trace = yes
>> TraceFile = /tmp/odbc.log
>>
>>
Did you change your code to use the query in forwardOnly mode?
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
std::cout << createConnection() << std::endl;
QSqlQuery query;
query.setForwardOnly(true);
query.exec("SELECT * FROM DATOS_ANTIGUOS.NOMBRE_COMUN");
std::cout << query.next() << std::endl;
std::cout << qPrintable(query.value(0).toString()) << std::endl;
return app.exec();
}
If this doesn't help then open qsql_odbc.cpp, search for SQL_OV_ODBC2
and replace it with SQL_OV_ODBC3.
--
[ signature omitted ]
Message 8 in thread
With setForwardOnly(true) i get with maxdb driver this at the end of odbc.log.
[ODBC][3091][SQLColAttribute.c][651]
Exit:[SQL_SUCCESS]
[ODBC][3091][SQLFetchScroll.c][152]
Entry:
Statement = 0x80d05c0
Fetch Orentation = 1
Fetch Offset = 0
[ODBC][3091][SQLFetchScroll.c][308]Error: IM001
[ODBC][3091][SQLGetDiagRec.c][735]
Entry:
Statement = 0x80d05c0
Rec Number = 1
SQLState = 0xbffedaba
Native = 0xbffedac4
Message Text = 0xbffed8b9
Buffer Length = 512
Text Len Ptr = 0xbffedaca
[ODBC][3091][SQLGetDiagRec.c][772]
Exit:[SQL_SUCCESS]
SQLState = IM001
Native = 0xbffedac4 -> 0
Message Text = [[unixODBC][Driver Manager]Driver does not support this function]
[ODBC][3091][SQLGetDiagRec.c][735]
Entry:
Statement = 0x80d05c0
Rec Number = 2
SQLState = 0xbffedaba
Native = 0xbffedac4
Message Text = 0xbffed8b9
Buffer Length = 512
Text Len Ptr = 0xbffedaca
and segmentation fault in program exec.
skuda pruebaodbc # ./pruebaodbc
1
Segmentation fault
But change SQL_OV_ODBC2 for SQL_OV_ODBC3 in qsql_odbc.cpp works with maxdb driver! with or without
setForwardOnly(true), so my problem seem to be fixed (i want to use maxdb driver), i have tested with
ingres for completeness and fails with this error in odbc.log:
[ODBC][11187][SQLFetchScroll.c][152]
Entry:
Statement = 0x8111258
Fetch Orentation = 2
Fetch Offset = 0
[ODBC][11187][SQLFetchScroll.c][339]
Exit:[SQL_ERROR]
DIAG [HY106] [Ingres][Ingres ODBC Driver]Invalid argument value
The same Select works with isql command line so i suposse it is anything in qt (i am not sure anyway).
I post here this ingres error to inform the list but my problem with maxdb driver it is fixed, many
thanks Anders :)
Best Regards,
Miguel Angel.
Anders Larsen escribió:
> Linos wrote:
>> I have saved the logs from the two odbc drivers i am testing (maxdb
>> and ingres), they are compressed in
>> this bzip file, they seems be failing in SQLFetchScroll.
>>
>> Anders Larsen escribió:
>>> Linos wrote:
>>>
>>> [...]
>>>> anyone can say me how i could do a more meaningful log or anything
>>>> else to help with that?
>>> Make sure that odbcinst.ini contains:
>>>
>>> [ODBC]
>>> Trace = yes
>>> TraceFile = /tmp/odbc.log
>>>
>>>
>
> Did you change your code to use the query in forwardOnly mode?
>
> int main(int argc, char *argv[])
> {
> QApplication app(argc, argv);
> std::cout << createConnection() << std::endl;
> QSqlQuery query;
>
> query.setForwardOnly(true);
>
> query.exec("SELECT * FROM DATOS_ANTIGUOS.NOMBRE_COMUN");
> std::cout << query.next() << std::endl;
> std::cout << qPrintable(query.value(0).toString()) << std::endl;
> return app.exec();
> }
>
> If this doesn't help then open qsql_odbc.cpp, search for SQL_OV_ODBC2
> and replace it with SQL_OV_ODBC3.
>
>
> --
> Anders L.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]
Message 9 in thread
Linos wrote:
> Hello,
> i am having a problem with qsqlquery in linux, i have tested in windows and it works ok, i am using qt
> 4.3.1, tested on gentoo and debian both, the odbc drivers i am using and the dsn are ok because it works
> well with isql unixodbc commandline making queries, the parameters to QSqlDatabase are ok, if i change
I'm running Debian + PostgreSQL ODBC driver for my app. It works fine
with Qt 4.3.1.
For version 3.3.8, I needed a patch to Qt code as stuff was not properly
escaped and return value of SQL_NO_DATA was not seen as a valid response
and Qt reported an error. But I have no problems with 4.3.1 so far...
I'm using UNIXOdbc with Unicode PostgreSQL driver.
unixodbc:
Installed: 2.2.11-16
odbc-postgresql:
Installed: 1:08.01.0200-2.1+b1
But I haven't had a problem with these for over a year now.
- Adam
--
[ signature omitted ]