Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_sql_kernel_qsqlresult.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QSqlDatabase>
4#include <QSqlQuery>
5#include <QSqlDriver>
6#include <QSqlError>
7#include <QSqlResult>
8#include <QDebug>
9
10// dummy typedef
11typedef void *sqlite3_stmt;
12
14{
15//! [0]
16QSqlQuery q;
17q.prepare("insert into test (i1, i2, s) values (?, ?, ?)");
18
19QVariantList col1;
20QVariantList col2;
21QVariantList col3;
22
23col1 << 1 << 3;
24col2 << 2 << 4;
25col3 << "hello" << "world";
26
27q.bindValue(0, col1);
28q.bindValue(1, col2);
29q.bindValue(2, col3);
30
31if (!q.execBatch())
32 qDebug() << q.lastError();
33//! [0]
34}
35
37{
38//! [1]
39QSqlDatabase db = QSqlDatabase::database("sales");
40QSqlQuery query("SELECT NAME, DOB FROM EMPLOYEES", db);
41
42QVariant v = query.result()->handle();
43if (v.isValid() && qstrcmp(v.typeName(), "sqlite3_stmt*") == 0) {
44 // v.data() returns a pointer to the handle
45 sqlite3_stmt *handle = *static_cast<sqlite3_stmt **>(v.data());
46 if (handle) {
47 // ...
48 }
49}
50//! [1]
51}
void querySqlite()
void insertVariants()
void * sqlite3_stmt