Questions tagged [qsqlquery]

The QSqlQuery class, part of the Qt framework, provides a means of executing and manipulating SQL statements.

QSqlQuery encapsulates the functionality involved in creating, navigating and retrieving data from SQL queries which are executed on a QSqlDatabase.

Documentation can be found here.

417 questions
155
votes
15 answers

Laravel : Syntax error or access violation: 1055 Error

I want to use WhereIn and Groupby in the same query to fetch Result. I've tried this: $loadids=explode("#@*",$reciptdet->loading_id); $loadingdatas=DB::table('loading')->groupBy('vehicle_no')->whereIn('id',$loadids)->get(); But I got this error…
Karthikvijayaveni
  • 1,864
  • 3
  • 13
  • 15
40
votes
2 answers

How to group items from database and display them - Android

I have receipt and logs model in android app. Receipt hasMany logs. I made query for group_by logs by sortID and grade. //recieve RecepitID and query to group logs final long forwardedId = (long)…
RubyDigger19
  • 835
  • 13
  • 38
14
votes
1 answer

Qt QSqlQuery bindValue works with ? but not with :placeholders

I'm working with SQLite, doing insert into table. Folowwing QSqlQuery testQuery(QString("INSERT INTO test(testcol) VALUES(?)")); testQuery.bindValue(0, someQStringObg); testQuery.exec(); works, but QSqlQuery testQuery(QString("INSERT INTO…
user3136871
  • 245
  • 2
  • 3
  • 8
9
votes
3 answers

QSqlQuery size() always returns -1

QSqlQuery query; QString queryText("SELECT * FROM section"); query.exec(queryText); qDebug() << query.size(); //always -1 while (query.next()) qDebug() << query.value(0).toString(); //got 16 records Method size() always returns -1. Help, please.…
Efog
  • 1,155
  • 1
  • 15
  • 33
8
votes
3 answers

QSqlQuery::prepare + MySQL ODBC Connector

I was using Qt's MySQL driver with 32bit MinGW Qt. This was working: QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); db.setDatabaseName("MyDatabase"); //SETUP if (db.open) { QSqlQuery q; if (q.prepare("SELECT id FROM Things WHERE…
smsware
  • 429
  • 1
  • 13
  • 41
7
votes
2 answers

Query Azure SQL Database using Rest-API

I have a SQL database server in Microsoft Azure. I want to use Azure Rest-API to select some records from a table. When I refer to Azure SQL Database REST API I can't find any section for this purpose, just I can get a DB information, server info or…
Sohrab
  • 1,348
  • 4
  • 13
  • 33
7
votes
2 answers

xml path returns "<" for < and ">" for > while executing query. how to get original value?

I have a query which results some text on the basis of condition in it. but do not worry about all the conditions, I am only facing issue when 'md.OtherMedication = 'OTHERMEDICATION' and its comment to be shown. So if comment have value like…
shubham bahuguna
  • 384
  • 4
  • 16
7
votes
2 answers

Qt 5 with SQLite: bindValue() results in "Parameter count mismatch" error

I'm doing a simple parameterized query with Qt 5.3.1 (64-bit) on Windows 7 using the SQLite driver. When I use bindValue() to set the value of the single parameter of my query, I systematically get the dreaded "Parameter count mismatch" error.…
François Beaune
  • 4,270
  • 7
  • 41
  • 65
7
votes
3 answers

Retrieving row count from QSqlQuery, but got -1

I'm trying to get the row count of a QSqlQuery, the database driver is qsqlite bool Database::runSQL(QSqlQueryModel *model, const QString & q) { Q_ASSERT (model); model->setQuery(QSqlQuery(q, my_db)); rowCount = model->query().size(); …
daisy
  • 22,498
  • 29
  • 129
  • 265
7
votes
1 answer

QSqlQuery with prepare and bindValue for column name Sqlite

void updateDB(const int id, const QString& column, const QVariant& value) const //***** //all stuff on open DB etc. QSqlQuery query; query.prepare("UPDATE table SET :column = :value WHERE id = :id "); query.bindValue(":column",…
Littlebitter
  • 671
  • 3
  • 10
  • 19
6
votes
1 answer

QT SQL datatype (QVariant) mapping for BINARY type of arbitrary length

I have a SQL query( call to a stored procedure to MSSQL) that takes arbitrary length of BINARY type as argument.I am using QT's support for stored procedure. But according to this, there is no corresponding QT type for varbinary for ODBC. QT…
msrepo
  • 63
  • 3
5
votes
1 answer

QSqlQuery for SQLite in forward iteration with next() will only find one row

The following problem has been discussed from time to time. However there was never a solution for the problem it self. As I found out there is a difference in iterating rows forward and backward. Forward iteration with QSqlQuery::next() may result…
bkausbk
  • 2,740
  • 1
  • 36
  • 52
4
votes
1 answer

Execute a %LIKE% query in Qt

I want to execute a parameterized in qt using value binding. This is the code: QString name = "Foo"; query->prepare("SELECT Name, Surname FROM employee WHERE Surname LIKE %:surname%"); query->bindValue(":surname", name); The problem is with the %…
beep
  • 1,057
  • 2
  • 11
  • 23
4
votes
1 answer

SQL: How to select distinct on some columns

I have a table looking something like this: +---+------------+----------+ |ID | SomeNumber | SomeText | +---+------------+----------+ |1 | 100 | 'hey' | |2 | 100 | 'yo' | |3 | 100 | 'yo' | <- Second occurrence |4 …
Rasmus Bækgaard
  • 1,748
  • 2
  • 10
  • 13
4
votes
3 answers

SQL query: Iterate over values in table and use them in subquery

I have a simple SQL table containing some values, for example: id | value (table 'values') ---------- 0 | 4 1 | 7 2 | 9 I want to iterate over these values, and use them in a query like so: SELECT value[0], x1 FROM (some subquery where…
Erik
  • 5,681
  • 8
  • 31
  • 32
1
2 3
27 28