函数参考


_SQLite_Query

准备 SQLite 查询

#include <SQLite.au3>
_SQLite_Query ( $hDB, $sSQL, ByRef $hQuery )

参数

$hDB 打开的数据库,如为 -1, 则使用最后打开的数据库
$sSQL 要执行的语句
$hQuery 传递出的查询句柄

返回值

成功: 返回 $SQLITE_OK
失败: 返回值可能违反 $SQLITE_* 常量@错误:
-1 - SQLite 报告错误 (检查返回值)
1 - 错误调用 SQLite API 'sqlite3_prepare16_v2'
2 - 调用被安全模式阻止

注意/说明

None.

相关

_SQLite_FetchData, _SQLite_FetchNames, _SQLite_Exec, _SQLite_GetTable, _SQLite_GetTable2d, _SQLite_QueryFinalize, _SQLite_QueryReset, _SQLite_QuerySingleRow, _SQLite_SetTimeout

示例/演示


#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $sMsg
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; 打开 :memory: 数据库
_SQLite_Exec(-1, "CREATE TABLE aTest (a,b,c);") ; 创建表
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');") ; 插入数据
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');") ; 插入数据
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');") ; 插入数据
_SQLite_Query(-1, "SELECT c FROM aTest ORDER BY a;", $hQuery) ; 查询
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
    $sMsg &= $aRow[0]
WEnd
_SQLite_Exec(-1, "DROP TABLE aTest;") ; 移除表
MsgBox(4096, "SQLite", "Get Data using a Query : " & $sMsg)
_SQLite_Close()
_SQLite_Shutdown()

;~ Output:
;~
;~ Hello World