Jump to content

SQLITE Error with autoit v3.3.14.3


Recommended Posts

Hi !

I installed the latest Version of AutoIt and my script witch uses SQLite does not works

As you can see 

Func Rtrn_HandleDb()

    _SQLite_Shutdown()
    _SQLite_Startup()

    $HandleDb = _SQLite_Open(@ScriptDir & "\DataSheets\DataBase.db")
;~  Print($HandleDb)

    Return $HandleDb

EndFunc   ;==>Rtrn_HandleDb


The return of my function is always at 0 and before I had values

 

you can also test the example : 

 

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

Local $hQuery, $aRow, $aNames
_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Open() ; open :memory: Database
_SQLite_Exec(-1, "CREATE TABLE aTest (A,B,C);")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');")
_SQLite_Exec(-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');")
_SQLite_Query(-1, "SELECT ROWID,* FROM aTest ORDER BY a;", $hQuery)
_SQLite_FetchNames($hQuery, $aNames)
ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CRLF)
While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK ; Read Out the next Row
    ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CRLF)
WEnd
_SQLite_QueryFinalize($hQuery)
_SQLite_Exec(-1, "DROP TABLE aTest;")
_SQLite_Close()
_SQLite_Shutdown()

; Output:
; rowid       A           B           C
; 3           a           1           Hello
; 2           b           3
; 1           c           2           World

and it does not work now.

After replacing on my include library these files  :

I did not see any changes

To my mind fixes are needed on sqlite.au3 and sqlite.dll.au3 (perhaps on the function _SQLITE_STARTUP ...)

Also when i use _ArrayDisplay the button under the tab as desappeared.

Great Thanks for supports and all your helps

 

bug array.jpg

Link to comment
Share on other sites

  • Moderators

danylarson,

We have split _ArrayDisplay (simple interface) and _DebugArrayDisplay (more complex interface) - read the change notes of the new release.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks for your Answer 

For the second example (_sqlite_fetchdata from helpfile) I gave I forgot to give the Error messages
 

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\dattias\Desktop\TNR-LIVE-REPORT\test.au3" /UserParams    
+>18:02:40 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:0000040C  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\dattias\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\dattias\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.3)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\dattias\Desktop\TNR-LIVE-REPORT\test.au3
+>18:02:40 AU3Check ended.rc:0
>Running:(3.3.14.3):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\dattias\Desktop\TNR-LIVE-REPORT\test.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
_SQLite_LibVersion=0
"C:\Users\dattias\Desktop\TNR-LIVE-REPORT\test.au3" (14) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CRLF)
ConsoleWrite(StringFormat(" %-10s  %-10s  %-10s  %-10s ", $aNames[0], ^ ERROR
->18:02:41 AutoIt3.exe ended.rc:1
+>18:02:41 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 0.6235

I ll read the change note (sorry I was affraid :) )

Thanks for all 
 

Link to comment
Share on other sites

Thanks for your help Adam 
  

The scripts worked properly on  3.3.14.2 and i Have a copy of the dll on the script folder.

Did you test the example script I mentioned ?

I think the things to do is to est Sqlite examples on help file.
They re not working properly now

 

Link to comment
Share on other sites


For example : 

Copy the script and the dll on a folder : 

#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


you ll see :
 

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\dattias\Desktop\TNR-LIVE-REPORT\test.au3" /UserParams    
+>10:56:39 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v.3.7.3.0   Keyboard:0000040C  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\dattias\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\dattias\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.3)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\dattias\Desktop\TNR-LIVE-REPORT\test.au3
+>10:56:39 AU3Check ended.rc:0
>Running:(3.3.14.3):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\dattias\Desktop\TNR-LIVE-REPORT\test.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
_SQLite_LibVersion=0
+>10:56:41 AutoIt3.exe ended.rc:0
+>10:56:41 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.622

To my mind , there is an issue blocking _Sqlite_Startup or _SQLite_Open function

The Msgbox supposed to show the Executed query does not show the query on  $sMsg

Thanks for your help and advices
 

Link to comment
Share on other sites

Hi,

On the previous Version , the sqlite.dll was downloaded and you said that the download was removed for some issues.

So I checked the function _Sqlite_startup : 

 

Func _SQLite_Startup($sDll_Filename = "", $bUTF8ErrorMsg = False, $iForceLocal = 0, $hPrintCallback = $__g_hPrintCallback_SQLite)
    If $sDll_Filename = Default Or $sDll_Filename = -1 Then $sDll_Filename = ""

    ; The $hPrintCallback parameter may look strange to assign it to $__g_hPrintCallback_SQLite as
    ; a default.  This is done so that $__g_hPrintCallback_SQLite can be pre-initialized with the internal
    ; callback in a single place in case that callback changes.  If the user overrides it then
    ; that value becomes the new default.  An empty string will suppress any display.
    If $hPrintCallback = Default Then $hPrintCallback = __SQLite_ConsoleWrite
    $__g_hPrintCallback_SQLite = $hPrintCallback

    If $bUTF8ErrorMsg = Default Then $bUTF8ErrorMsg = False
    $__g_bUTF8ErrorMsg_SQLite = $bUTF8ErrorMsg

    Local $sDll_Dirname = ""
    If $sDll_Filename = "" Then $sDll_Filename = "sqlite3.dll"
    If @AutoItX64 And (StringInStr($sDll_Filename, "_x64") = 0) Then $sDll_Filename = StringReplace($sDll_Filename, ".dll", "_x64.dll")

    Local $iExt = 0
    If $iForceLocal < 1 Then
        Local $bDownloadDLL = True
        Local $vInlineVersion = Call('__SQLite_Inline_Version')
        If @error Then $bDownloadDLL = False ; no valid SQLite version define so invalidate download

        If $iForceLocal = 0 Then
            ; check SQLite version if local file exists
            If __SQLite_VersCmp(@ScriptDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
                $sDll_Dirname = @ScriptDir & "\"
                $bDownloadDLL = False
            ElseIf __SQLite_VersCmp(@SystemDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
                $sDll_Dirname = @SystemDir & "\"
                $bDownloadDLL = False
            ElseIf __SQLite_VersCmp(@WindowsDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
                $sDll_Dirname = @WindowsDir & "\"
                $bDownloadDLL = False
            ElseIf __SQLite_VersCmp(@WorkingDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
                $sDll_Dirname = @WorkingDir & "\"
                $bDownloadDLL = False
            Else
                $sDll_Filename = StringReplace($sDll_Filename, ".dll", "") & "_" & $vInlineVersion &  ".dll"
                If __SQLite_VersCmp(@ScriptDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
                    $sDll_Dirname = @ScriptDir & "\"
                    $bDownloadDLL = False
                ElseIf __SQLite_VersCmp(@SystemDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
                    $sDll_Dirname = @SystemDir & "\"
                    $bDownloadDLL = False
                ElseIf __SQLite_VersCmp(@WindowsDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
                    $sDll_Dirname = @WindowsDir & "\"
                    $bDownloadDLL = False
                ElseIf __SQLite_VersCmp(@WorkingDir & "\" & $sDll_Filename, $vInlineVersion) = $SQLITE_OK Then
                    $sDll_Dirname = @WorkingDir & "\"
                    $bDownloadDLL = False
                EndIf
            EndIf
        EndIf

        If $bDownloadDLL Then
            If Not FileExists($sDll_Dirname & $sDll_Filename) Then
                ; Create in @LocalAppDataDir & "\AutoIt v3\" to avoid reloading (only valid for the current user)
                $sDll_Dirname = @LocalAppDataDir & "\AutoIt v3\SQLite"
            EndIf
            If $iForceLocal Then
                ; download the latest version. Usely related with internal testing.
                $vInlineVersion = ""
            Else
                ; download the version related with the include version
                $vInlineVersion = "_" & $vInlineVersion
                $iExt = 1
            EndIf
            $sDll_Filename = $sDll_Dirname & "\" & StringReplace($sDll_Filename, ".dll", "") &  $vInlineVersion &  ".dll"
;~          $sDll_Filename = __SQLite_Download_SQLite3File($sDll_Dirname, StringReplace($sDll_Filename, ".dll", ""), $vInlineVersion, ".dll")
;~          If @error Then Return SetError(@error, @extended, "") ; download not successful
;~          $iExt = @extended
        EndIf
    EndIf
;~  If Not FileExists($sDll_Filename) Then Then Return SetError(2, 0, "") ; File not found

    Local $hDll = DllOpen($sDll_Filename)
    If $hDll = -1 Then
        $__g_hDll_SQLite = 0
        Return SetError(1, $iExt, "")
    Else
        $__g_hDll_SQLite = $hDll
        Return SetExtended($iExt, $sDll_Filename)
    EndIf
EndFunc   ;==>_SQLite_Startup

As you can see, on the code the download is already there

if you check the value   : $sDll_Filename

You ll see that it leads to the path : 

C:\Users\dattias\AppData\Local\AutoIt v3\SQLite\sqlite3_302200000_302200000.dll

witch is wrong

So to make my script works I use the call  

   _SQLite_Startup("Sqlite3.dll",False,1)

instead of    

  _SQLite_Startup()

If the downloas is desactivated the block before is legacy

 

Great Thanks to Adam witch gave to me the idea to debug this function 
and to Melba witch is working hard for us :)


 

Link to comment
Share on other sites

I tested multiple examples, include the yours above, and have not had any issues.  The sqlite3.dll is in the script directory.  On your example, add a ConsoleWrite for the _SQLite_Startup function, and see what dll it is using.  

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

Local $hQuery, $aRow, $sMsg
ConsoleWrite("SQLite DLL path=" & _SQLite_Startup() & @CRLF) 
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

 

Adam

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...