Unable to CREATE TABLE; why does this code fail?

那年仲夏 提交于 2019-12-12 20:19:29

问题


I have a problem with SQLite v3.22.0 and AutoIt v3.3.14.3. Trying to create a database works but the table does not get created. I use the AutoIt example code:

#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

If I request the SQLite error, I get "Library used incorrectly". What's the problem in this case?


回答1:


Whats the problem in this case?

As per Documentation - Script breaking changes :

_SQLite_Startup() function no longer automatically downloads the SQLite DLL files from autoitscript.com. Most users were completely unaware that this download was occuring on each script run and it was also a severe bandwidth hog for the website. The SQLite DLLs must now be manually download. See the _SQLite_Startup() documentation for details.

If _SQLite_Startup()'s first parameter is omitted, then dll file must reside in @SystemDir, @WindowsDir, @ScriptDir or @WorkingDir for this function to succeed.

  1. Download sqlite3.dll,
  2. remove #include <SQLite.dll.au3>, then
  3. provide _SQLite_Startup()'s first parameter with location of dll file (redundant if present in one of four previously mentioned locations).

Related.




回答2:


AutoIt v3.3.14.3 has a bug; install AutoIt v3.3.14.2 or get the bug-fix.



来源:https://stackoverflow.com/questions/48990852/unable-to-create-table-why-does-this-code-fail

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!