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. QSqlError trying to insert a QByteArray in a postgres DB
Forum Updated to NodeBB v4.3 + New Features

QSqlError trying to insert a QByteArray in a postgres DB

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 199 Views
  • 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.
  • Y Offline
    Y Offline
    Yoriik
    wrote on last edited by
    #1

    Hello there,

    when trying the above I'm getting the following error:
    QSqlError("42601", "QPSQL: Unable to create query", "ERROR: syntax error at end of input\nLINE 1: EXECUTE \n ^\n(42601)")

                    db.transaction();
    		QSqlQuery query(db);
    		query.prepare("UPDATE "+par->get_name()+" SET ausgabe_name=':name_out', ausgabe_datei=':f_out' WHERE experimentid=':exp_id'");
    		query.bindValue(":name_out",output);
    		query.bindValue(":f_out",output_byte_array);
    		query.bindValue(":exp_id", ui->lineEdit_experiment_id->text());
    		query.exec();
    		qDebug()<<query.lastError();
    		db.commit();
    

    Thanks in advance

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      Yoriik
      wrote on last edited by
      #2

      Figured it out. the ' around the placeholders were the problem so this seems to work:

                      db.transaction();
      		QSqlQuery query(db);
      		query.prepare("UPDATE "+par->get_name()+" SET ausgabe_name=:name_out, ausgabe_datei=:f_out WHERE experimentid=:exp_id");
      		query.bindValue(":name_out",output);
      		query.bindValue(":f_out",output_byte_array);
      		query.bindValue(":exp_id", ui->lineEdit_experiment_id->text());
      		query.exec();
      		qDebug()<<query.lastError();
      		db.commit();
      
      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