【问题标题】:Unable to CREATE TABLE; why does this code fail?无法创建表;为什么这段代码会失败?
【发布时间】:2018-02-26 14:33:17
【问题描述】:

我对 SQLite v3.22.0 和 AutoIt v3.3.14.3 有疑问。尝试创建数据库有效,但未创建表。我使用 AutoIt 示例代码:

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

Local $hQuery, $aRow, $sMsg
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TABLE aTest (a,b,c);") ; CREATE a Table
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');") ; INSERT Data
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');") ; INSERT Data
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');") ; INSERT Data
_SQLite_Query(-1, "SELECT c FROM aTest ORDER BY a;", $hQuery) ; the query
While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK
    $sMsg &= $aRow[0]
WEnd
_SQLite_Exec(-1, "DROP TABLE aTest;") ; Remove the table
MsgBox($MB_SYSTEMMODAL, "SQLite", "Get Data using a Query : " & $sMsg)
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; Hello World

如果我请求 SQLite 错误,我会得到“库使用不正确”。这种情况有什么问题?

【问题讨论】:

    标签: sqlite autoit


    【解决方案1】:

    这种情况有什么问题?

    根据Documentation - Script breaking changes

    _SQLite_Startup() 函数不再自动从 autoitscript.com 下载 SQLite DLL 文件。大多数用户完全不知道每次脚本运行时都会发生这种下载,这也是网站严重的带宽占用。现在必须手动下载 SQLite DLL。有关详细信息,请参阅_SQLite_Startup() 文档。

    如果_SQLite_Startup()的第一个参数被省略,则dll文件必须驻留在@SystemDir@WindowsDir@ScriptDir@WorkingDir中才能成功。

    1. Download sqlite3.dll,
    2. 删除#include &lt;SQLite.dll.au3&gt;,然后
    3. _SQLite_Startup() 的第一个参数提供 dll 文件的位置(如果存在于前面提到的四个位置之一,则为冗余)。

    Related.

    【讨论】:

    • 现在尝试了许多可能的解决方案。它们都不起作用。如果我尝试获取 lib 版本,我会得到 3.22.0,所以库在那里并且已加载,但我使用 autoit 运行的所有操作都失败了。
    【解决方案2】:

    AutoItv3.3.14.3 has a bug;安装 AutoIt v3.3.14.2 或get the bug-fix

    【讨论】:

      猜你喜欢
      • 2013-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多