Qt and MySQL C API

  • Hi, I'm using MySQL C connector to connect to my database. My tables are in UTF-8 format. When I try to read my data I haven't right output. Here is my code:
    @my_ulonglong rows;
    mysql_query(&conn, command.toAscii().data());
    res = mysql_store_result(&conn);
    QList<QList<QString> > vysledok;
    int i;
    QList<QString> riadok;
    while ((row = mysql_fetch_row(res)) != NULL) {
    for (i = 0; i < rows; i++) {
    QString temp;
    temp = QString::fromUtf8(row[i]);
    qDebug() << temp;
    return vysledok;@
    And my screen with debug error is here:

    My application output is:
    @Debugging starts
    "Website administrator"
    Debugging has finished@

  • I can't see why you don't use Qt MySQL plugin...

  • I have some problems with compilation of plugin

  • What problems? I had problems too, but finally had success on Windows using MinGW 4.6 and MySQL 5.1.3 libraries.

    On Linux you don't need to compile. They already exist some packages ;)

  • While compilation I had problems with MySQL lib source, On Linux I haven't problems, but now I'm on W7. Finally, yesterday I managed to compile QMYSQL module with Qt 4.8.1, MySQL C Connector 6.0.2 and with MSVC 2010

  • Hi Sibyx,

    You can try this code:


    mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "utf8");
    mysql_options(&mysql, MYSQL_INIT_COMMAND, "SET NAMES utf8");



Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.