Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt and MySQL C API
Forum Updated to NodeBB v4.3 + New Features

Qt and MySQL C API

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sibyx
    wrote on last edited by
    #1

    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) {
    riadok.clear();
    for (i = 0; i < rows; i++) {
    QString temp;
    temp = QString::fromUtf8(row[i]);
    qDebug() << temp;
    }
    }
    mysql_free_result(res);
    return vysledok;@
    And my screen with debug error is here:
    !http://mksoft.marconet.sk/mysql_debug.jpg(Output)!

    My application output is:
    @Debugging starts
    "1"
    "Administrator"
    "Website administrator"
    "??01??0????????0??0??0?+1?2"
    Debugging has finished@

    1 Reply Last reply
    0
    • S Offline
      S Offline
      soroush
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sibyx
        wrote on last edited by
        #3

        I have some problems with compilation of plugin

        1 Reply Last reply
        0
        • S Offline
          S Offline
          soroush
          wrote on last edited by
          #4

          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 ;)

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sibyx
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JimmyChung
              wrote on last edited by
              #6

              Hi Sibyx,

              You can try this code:

              mysql_init(&mysql);

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

              mysql_real_connect(&mysql,CTH_SERVER,CTH_USER,CTH_PASSWORD,CTH_DB_IN,0,0,0));

              :)

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved