Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. query
    Log in to post

    • SOLVED QSqlQuery produces error if containing two equally named placeholders
      General and Desktop • sql query placeholder • • napajejenunedk0  

      7
      0
      Votes
      7
      Posts
      1280
      Views

      @Christian-Ehrlicher, thanks for the guidance. Marking the topic as solved, since a Qt fix is presumably being awaited. Filed a bug report.
    • SOLVED SQLite WHERE clause with BLOB. Or how to make QT query BLOB as x'00000000'?
      General and Desktop • sql sqlite qsqlquery query • • Kofr  

      6
      0
      Votes
      6
      Posts
      5410
      Views

      @Kofr If the above snippet works, then you don't respect the SQL's type. You're trying to pass a string representation to Qt when it clearly expects a binary (BLOB is "Binary Large OBject"). So then the question: How to fix Qt implementation? comes back as: "How to fix your implementation". Anyway, I'd suggest passing the appropriate type to the driver. My thoughts are that something like this should be working: const char rawData[4] = { 0x00, 0x00, 0x00, 0x07 }; QByteArray id = QByteArray::fromRawData(rawData, 4); QSqlQuery query; if (!query.prepare(QStringLiteral("SELECT row FROM %1 WHERE id = :id").arg(tableName))) // Handle the error! query.bindValue(":id", id); // Pass binary data for columns that expect binary if (!query.exec()) // Handle error again!
    • UNSOLVED Check if a row exists Update Record, otherwise insert In Database
      General and Desktop • update query sqlserver • • M4RZB4Ni  

      6
      0
      Votes
      6
      Posts
      6112
      Views

      If you have SQL server why not just create a stored procedure in the server and call it in C++?! It's the best option under all circumstances. If you can't use that then use a select then use something like: bool alreadyExist = false; { QSqlQuery query; query.prepare("select * from MyTable where rowID=:rowID"); query.bindValue(":rowID",rowID); if(!query.exec()){ // select failed } alreadyExist = query.next(); } if(alreadyExist){ // update } else{ //insert }
    • SOLVED Check if a query has finished
      General and Desktop • query finished • • cxam  

      2
      0
      Votes
      2
      Posts
      699
      Views

      @cxam Hahaha Solved, easily with "query.isActive". Sorry for the stupid question
    • SOLVED QTableWidget and SQL (dynamic) not working
      General and Desktop • sql qtablewidget sqlite query • • cxam  

      12
      0
      Votes
      12
      Posts
      4502
      Views

      @SGaist Indeed, you're right When I set the properties for my table I set that the number of rows was "1" so I have to create an "int" variable and then say that the number of rows is that variable starting from 1 and then increment that number on the loop.
    • SOLVED Filter by Date on a SQLITE
      General and Desktop • sqlite qstring query qdate date • • cxam  

      4
      0
      Votes
      4
      Posts
      5760
      Views

      @the_ @SGaist Hi, I managed to solve it on my own by encoding the date to a JulianDate and using juliandate on my db so it's much easier to compare and so. Thanks for your help.
    • UNSOLVED Help with SQL Query
      General and Desktop • sql qsql query • • cxam  

      7
      0
      Votes
      7
      Posts
      1957
      Views

      lastQuery should return the actually query that ran against the database, that one would be interesting to see. Good point of @paul-colby
    • SOLVED QTableWidget not showing SQL Query.
      General and Desktop • sql qtablewidget query select • • cxam  

      10
      0
      Votes
      10
      Posts
      5217
      Views

      @mrjj Ok so, it seems that it doesn't detect the table "usuarios" even though it's there... So in my sqlite editor I executed the command and it worked properly: http://s18.postimg.org/iqry91pmx/image.png EDIT: I solved that problem: the program was searching the db in the remote directory not in the real directory, now it doesn't says any error but It doesn't shows the information. I've tried (SELECT * FROM usuarios) but nothing, it doesn't works. 2ND EDIT: I solved the problem, it was on my printing method, I tried a much simpler methor by doing: int i=0; while (query.next()) { ui->tableWidget->setItem(i,0,new QTableWidgetItem(query.value(0).toString())); ui->tableWidget->setItem(i,1,new QTableWidgetItem(query.value(1).toString())); ui->tableWidget->setItem(i,2,new QTableWidgetItem(query.value(2).toString())); i++; ui->tableWidget->insertRow(i); } Thank you for your help.
    • SOLVED Problem with Query - QODBC, Informix
      General and Desktop • query qodbc informix • • Mich.Q  

      15
      0
      Votes
      15
      Posts
      5545
      Views

      @mrjj thank you still
    • SOLVED Looping through query results and displaying in tableview
      General and Desktop • query tableview table • • gabor53  

      3
      0
      Votes
      3
      Posts
      1635
      Views

      Thank you. It worked.
    • UNSOLVED Query dispays memory address instead of variable value
      General and Desktop • model qstandarditem query • • gabor53  

      4
      0
      Votes
      4
      Posts
      1304
      Views

      You're setting the wrong role. See my answer here.
    • [SOLVED] Quering Enginio with QML
      Mobile and Embedded • qml query enginio • • guidupas  

      25
      0
      Votes
      25
      Posts
      7882
      Views

      https://forum.qt.io/category/10/general-and-desktop -> "New Topic" button
    • Querying database with list of dynamic values
      General and Desktop • database sqlite selection binding query • • fralik  

      2
      0
      Votes
      2
      Posts
      925
      Views

      Hi, Do you mean get additional data using QSqlQuery ?
    • Get values from SQLite row using last_insert_rowid()
      General and Desktop • sql sqlite query • • Jorge  

      2
      0
      Votes
      2
      Posts
      3059
      Views

      HI and welcome to devnet, usually a SELECT statement is in the form SELECT <field_list> FROM <table_name> WHERE <conditions>; in your queries there's no FROM <tablename>. BTW, QSqlQuery::exec() returns a boolean and you can check the errors with QSqlQuery::lastError() bool result = query.exec(...); if (!result) { qDebug() << "Error: " << query.lastError().text(); }