本帖最后由 blue_dvd 于 2016-7-14 22:17 编辑
第一次写数据库,没想到使用例子都无法运行,请高手指点:#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
Local $aResult, $iRows, $iColumns, $iRval
_SQLite_Startup()
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite 错误", "SQLite.dll 不能加载!")
Exit -1
EndIf
ConsoleWrite("SQLite 库版本 = " & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; 打开一个 :内存: 数据库
If @error Then
MsgBox($MB_SYSTEMMODAL, "SQLite 错误", "无法加载数据库!")
Exit -1
EndIf
; 示例表
; 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 错误", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite 错误", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite 错误", _SQLite_ErrMsg())
If Not _SQLite_Exec(-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
MsgBox($MB_SYSTEMMODAL, "SQLite 错误", _SQLite_ErrMsg())
; 查询
$iRval = _SQLite_GetTable2d(-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
_SQLite_Display2DResult($aResult)
; $aResult 结果看起来像这样:
; Name Age
; Alice 43
; Bob 28
; Cindy 21
; 如果格式被切换, _SQLite_GetTable2d 结果将是这样的:
; Name Alice Bob Cindy
; Age 43 28 21
Else
MsgBox($MB_SYSTEMMODAL, "SQLite 错误: " & $iRval, _SQLite_ErrMsg())
EndIf
_SQLite_Close()
_SQLite_Shutdown()
执行后的错误
请高手帮忙解决,多谢了!
AUTOIT版本号V3.3.14.2第四版,最新安装版。win7 32位
用3.3.9版本的库文件就可以了! |