[Qt-interest] Question about QSqlDatabase, AS/400 and encoding / charset
Robert Hairgrove
evorgriahr at hispeed.ch
Tue Dec 29 15:31:33 CET 2009
Luca Manganelli wrote:
> Hi,
>
> I'm using PyQT4 4.5.1.
>
> I use QSqlDatabase to connect with the AS/400 IBM Client Access ODBC driver.
>
> I use QSqlQueryModel to represent a query to a QTableView.
>
> My problem is that the data in the QTableView are represented in
> EDBCIC format, while I want them in utf8 format.
>
> The code listing follows:
>
> conn = QSqlDatabase().addDatabase("QODBC")
> conn.setDatabaseName("DBNAME")
> conn.setUserName("...")
> conn.setPassword("...")
> cur = QSqlQueryModel ()
> cur.setQuery ("SELECT * FROM IMMOBCATAS WHERE convert(varchar,
> collationproperty(name, 'CodePage')) = '870'", conn)
>
> How can I set encoding in QSqlDatabase?
I believe you need to set the encoding either in the ODBC datasource or
in the Client Access connection properties. If you can connect to the
DSN with some other application, can you see the data presented
normally? If so, it should work with QtSql as well.
More information about the Qt-interest-old
mailing list