本帖最后由 netegg 于 2011-5-27 07:54 编辑 #include <SQLite.au3>
#include <SQLite.dll.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
Global $edit
_Main()
Func _Main()
Local $GUI, $hQuery, $aRow, $aNames
$GUI = GUICreate("SQLite FetchData", 400, 260)
$edit = GUICtrlCreateEdit("", 2, 2, 394, 256, BitOR($ES_READONLY, $ES_AUTOVSCROLL))
GUISetState()
_SQLite_Startup ()
MemoWrite("_SQLite_LibVersion=" &_SQLite_LibVersion() & @CR)
_SQLite_Open () ; 打开:内存:数据库
_SQLite_Exec (-1, "CREATE table aTest ('姓名','年龄','学历');")
_SQLite_Exec (-1, "INSERT INTO aTest('姓名','年龄','学历') VALUES ('张三','2','幼儿园大班');")
_SQLite_Exec (-1, "INSERT INTO aTest('姓名','年龄','学历') VALUES ('李四','3','幼儿园辍学 ');")
_SQLite_Exec (-1, "INSERT INTO aTest('姓名','年龄','学历') VALUES ('王五','1','幼儿园开除');")
_SQlite_Query (-1, "SELECT ROWID,* FROM aTest ORDER BY 姓名;", $hQuery)
_SQLite_FetchNames ($hQuery, $aNames)
MemoWrite($aNames[0] & @tab & $aNames[1] & @tab & $aNames[2] & @tab & $aNames[3] & @CR)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK ; 读出下一行
MemoWrite( $aRow[0] & @tab & $aRow[1] & @tab & $aRow[2] & @tab & $aRow[3] & @CR)
WEnd
_SQLite_Exec (-1, "DROP table aTest;")
_SQLite_Close ()
_SQLite_Shutdown ()
; 循环至用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func memowrite($s_text)
GUICtrlSetData($edit, $s_text & @CRLF, 1)
EndFunc ;==>memowrite
|