Qt-interest Archive, December 2007
Re: ODBC QSqlquery bool QVariant Problem
Message 1 in thread
Linos wrote:
> Hello,
> i have this problem with odbc driver in linux, if i prepare a statement and bind a value like this (python
> PyQt4 code):
>
>
> query = QSqlquery()
> variant = QVariant(True)
>
> query.prepare(QString("INSERT INTO TEST (COLUMNTEST) VALUES (?)"))
> query.addBindValue(variant)
> query.exec_()
>
> -------------------------------------
> "query.lastError().text()" prints "Invalid character value for cast specification"
> "variant.toBool()" prints "True"
> "variant.toInt()[0] prints "1"
>
> if i change "query.addBindValue(variant)" for this:
>
> query.addBindValue(QVariant(variant.toInt()[0]))
>
> it works ok, can be this a bug or it is any problem in my code?
>
> Best Regards,
> Miguel Angel.
>
>
Possibly your code, I'm not sure on the specifics of the engine that
you're connecting to, but it could be that it doesn't support true. A
lot of them don't. I guess first steps here is determining what the
database stores the field as. integer or string, and converting to that
type (like you're doing with the toInt() call).
Hope this helps.
--
[ signature omitted ]