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
11
typedef
void
*
sqlite3_stmt
;
12
13
void
insertVariants
()
14
{
15
//! [0]
16
QSqlQuery q;
17
q.prepare(
"insert into test (i1, i2, s) values (?, ?, ?)"
);
18
19
QVariantList col1;
20
QVariantList col2;
21
QVariantList col3;
22
23
col1 << 1 << 3;
24
col2 << 2 << 4;
25
col3 <<
"hello"
<<
"world"
;
26
27
q.bindValue(0, col1);
28
q.bindValue(1, col2);
29
q.bindValue(2, col3);
30
31
if
(!q.execBatch())
32
qDebug() << q.lastError();
33
//! [0]
34
}
35
36
void
querySqlite
()
37
{
38
//! [1]
39
QSqlDatabase db = QSqlDatabase::database(
"sales"
);
40
QSqlQuery query(
"SELECT NAME, DOB FROM EMPLOYEES"
, db);
41
42
QVariant v = query.result()->handle();
43
if
(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
}
querySqlite
void querySqlite()
Definition
src_sql_kernel_qsqlresult.cpp:36
insertVariants
void insertVariants()
Definition
src_sql_kernel_qsqlresult.cpp:13
sqlite3_stmt
void * sqlite3_stmt
Definition
src_sql_kernel_qsqlresult.cpp:11
qtbase
src
sql
doc
snippets
code
src_sql_kernel_qsqlresult.cpp
Generated on
for Qt by
1.14.0