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. Qsqlquery: problem with multiple queries at the same time.
Forum Updated to NodeBB v4.3 + New Features

Qsqlquery: problem with multiple queries at the same time.

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.2k 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
    spruzzer
    wrote on last edited by
    #1

    I wrote some widgets which I instantiate in a main window. Every widget is bound to a database using a class called dbManager, which implements a qtsqldatabse object and some functions to insert into the db tables. The dbManager cass is passed as reference to every widget in order to have a singe database connection. When I'm inserting record into the db (a threaded Class) and I want to browse the tabe content I get this message:

    Unable to free statement: lost synchronization with server: got message type "?", length -33673258

    and the program crash.

    To load data into the db entries browser I use this pattern to update the shown data:

    @ QSqlQuery query;
    query.prepare("SELECT T.content FROM tweet T WHERE T.topic = :topic AND LANGUAGE = :language AND NOT EXISTS (SELECT V.tweet_id FROM voted_tweet V WHERE T.tweet_id = V.tweet_id)");
    query.bindValue(":topic",arg1);
    query.bindValue(":language",ui->langSelector->currentText());
    query.exec();
    queryModelcol->setQuery(query);
    ui->tableView->setModel(queryModelcol);

        //  --- Full Model
        QSqlQuery query2;
        query2.prepare("SELECT * FROM tweet T WHERE T.topic = :topic AND LANGUAGE = :language AND NOT EXISTS (SELECT V.tweet_id FROM voted_tweet V WHERE T.tweet_id = V.tweet_id)");
        query2.bindValue(":topic",arg1);
        query2.bindValue(":language",ui->langSelector->currentText());
        query2.exec();
        queryModelrow->setQuery(query2);@
    

    In the DB manager cass records are inserted in the folowing way:

    @QSqlQuery query;
    query.prepare("INSERT INTO TWITTER_USER (user_id, name, language, img)"
    "VALUES (:user_id, :name, :language, :img)");

    query.bindValue(":user_id", data.at(0).toUtf8().constData());
    query.bindValue(":name", data.at(1).toUtf8().constData());
    query.bindValue(":language", data.at(2).toUtf8().constData());
    query.bindValue(":img", data.at(3).toUtf8().constData());
    if (query.exec() )
        return true;
    else
        return false;@
    

    I'm using PostgreSql with the psql driver on Windows. I tryed to set transactions for every query execution and also to use a single query object with .finish() function, but the result is Always the same.
    Do you have suggestions to find a way to solve the error?

    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