Retourne ou écrit dans la Console un affichage formaté d'un tableau de dimension 2
#include <SQLite.au3>
_SQLite_Display2DResult ( $aResult [, $iCellWidth = 0 [, $bReturn = False]] )
$aResult | Le tableau à afficher |
$iCellWidth | [optionnel] Spécifie la taille du champ de données |
$bReturn | [optionnel] Si True, la chaîne formatée est retournée, elle ne s'affiche pas Si False, la chaîne formatée est envoyée à StdOut |
Succès: | Retourne rien ou une chaîne formatée. |
Échec: | Définit @error <> 0. |
@error: | 1 - $aResult n'est pas un tableau ou a une dimension invalide |
#include <MsgBoxConstants.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Local $aResult, $iRows, $iColumns, $iRval _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() ; Ouvre une base de données :memory: If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't Load Database!") Exit -1 EndIf ; Exemple de 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()) ; Query $iRval = _SQLite_GetTable2d(-1, "SELECT * FROM persons; ", $aResult, $iRows, $iColumns) If $iRval = $SQLITE_OK Then _SQLite_Display2DResult($aResult) ; $aResult looks like this: ; Name Age ; Alice 43 ; Bob 28 ; Cindy 21 ; If the dimensions would be switched in _SQLite_GetTable2d the result would look like this: ; Name Alice Bob Cindy ; Age 43 28 21 Else MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg()) EndIf _SQLite_Close() _SQLite_Shutdown()