Results 1 to 4 of 4

Thread: QT library & ODBC

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Question QT library & ODBC

    Hello,
    i try store utf8 strings with UPDATE, INSERT with QT application (ODBC driver) and characters not save propertly.
    SET NAMES utf8; not work, any idea?

    (libmysql work fine)

    code:
    query.bindValue(":name", (QString)m_name);
    and i try new:
    query.bindValue(":name", m_name.toUtf8());
    with no effect, this look at problem in driver

    but select * work fine...


    input:

    qpos 2b0c-2f54 ENTER SQLGetData
    HSTMT 00C6A0E0
    UWORD 2
    SWORD -8 <SQL_C_WCHAR>
    PTR 0x03B200B0
    SQLLEN 102
    SQLLEN * 0x0025F958

    qpos 2b0c-2f54 EXIT SQLGetData with return code 0 (SQL_SUCCESS)
    HSTMT 00C6A0E0
    UWORD 2
    SWORD -8 <SQL_C_WCHAR>
    PTR 0x03B200B0 [ 24] "Petr Vom\ff\ffka"
    SQLLEN 102
    SQLLEN * 0x0025F958 (24)

    result:


    qpos 2b0c-2f54 ENTER SQLBindParameter
    HSTMT 00C6A0E0
    UWORD 1
    SWORD 1 <SQL_PARAM_INPUT>
    SWORD 1 <SQL_C_CHAR>
    SWORD 12 <SQL_VARCHAR>
    SQLULEN 14
    SWORD 0
    PTR 0x03E3BE68
    SQLLEN 14
    SQLLEN * 0x0025FA60

  2. #2
    Join Date
    Sep 2009
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT library & ODBC

    I think I might have the same problem...
    I use Qt 4.5.2 and connect to MySQL database using ODBC.

    I have a database which contains utf-8 data (accented characters, cyrillic...), and all the characters display correctly in tableView and lineEdit.

    But when you insert/update the model/database it garbles the data showing "crazy" characters. It is regardles if the editing happened in the grid directly, or with setData() or with insertRecord, and regardles of providing the value as a string from code or from lineEdit. I was very puzzled with the fact that when I retreive a field from the database and put the retrieved value in a lineEdit, it is displayed correctly, and when I put lineEdit.text() with setData() back to the database (should be the same string?) it updates wrong.

    Also trited .toUtf8 and similar.... no success?

    Did you manage to solve your problem? Anyone?

    P.S. using plain lineEdit.text() which is "abcd Å¡đčć" a get in the database something like "abcd šđčć"
    Last edited by toroman; 27th September 2009 at 01:09.

  3. #3
    Join Date
    Sep 2009
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT library & ODBC

    I have done some investigation and here is what I have found.... funny

    I enabled logging of the SQL from MyODBC driver (Windows) and here is what I get:

    UPDATE `OBVEZ` SET `ID`=_latin1'634', `REGBR`=_latin1'', `NAZIV`=_latin1'Dragan Toroman', `IME`=_latin1'Dragan Toroman', `ADRESA`=_latin1'12 Å¡đ шђ', `MESTO`=_latin1'Some Place', `TACKA`=_latin1'13', `KOL`=_latin1'1', `IZBACI`=0, `PREBACEN`=0 WHERE `ID` = 634;

    notice _latin1 WTF put that in there?

    Investigating further....

  4. #4
    Join Date
    Sep 2009
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT library & ODBC

    I reverted to 3.51 instead of 5.1.5. myodbc, and everything works fine...

    I have also asked the question about introducers (_latin1) on mysql forum... waiting for reply.
    Funny there is a settion of charset in 3.51 which I have set to utf8, but no such setting in 5.1.5

Similar Threads

  1. Replies: 4
    Last Post: 18th December 2009, 18:55
  2. plugin in a library
    By alisami in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2008, 17:21
  3. Loading library from application
    By mourad in forum Installation and Deployment
    Replies: 0
    Last Post: 2nd April 2008, 15:10
  4. Adding library dependencies to qmake
    By sadastronaut in forum Installation and Deployment
    Replies: 2
    Last Post: 18th March 2008, 17:06
  5. Replies: 1
    Last Post: 5th March 2007, 20:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.