Code : Tout sélectionner
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <MsgBoxConstants.au3>
#include <file.au3>
Local $aResult, $iRows, $iColumns, $iRval, $ligne1
Local $hQuery, $aRow
_SQLite_Startup()
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit -1
EndIf
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; Open a :memory: database
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!")
Exit -1
EndIf
; Example Table
; Name | Age
; -----------------------
; Alice | 43
; Bob | 28
; Cindy | 21
If Not _SQLite_Exec(-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Cindy2','21');") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Cindy2','21');") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite Error", _SQLite_ErrMsg())
; Query
$iRval = _SQLite_GetTable2d(-1, "SELECT * FROM persons WHERE Age = '21';", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
_FileCreate(@ScriptDir & "\" & $iRows & " enregistrement pour 21ans.txt")
_FileWriteFromArray($iRows & " enregistrement_pour_21ans.txt", $aResult)
Else
MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg())
EndIf
_SQLite_Close()
_SQLite_Shutdown()