Sign in to follow this  
Followers 0
Colyn1337

Help with _SQLite_Startup() Failure

9 posts in this topic

#1 ·  Posted (edited)

So,

I wrote this script which is a license fetcher and auto installer. It grabs the license code from a sqlite database file on a network share. The problem is, sometimes _SQLite_Startup() works, other times it produces an error. On my computer (64bit) and my VM's (32bit) everything goes well. Randomly in deployment, a computer will fail at the _SQLite_Startup() command. This is very frustrating because I cannot isolate a unique condition to the computers that fail. They're all Windows 7, some are 64 others are 32, in all cases the user has admin rights. Any guidance or thoughts would be appreciated.

As I would want to see the code to offer assistance, please find mine below:

#NoTrayIcon

#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <File.au3>
#include <Array.au3>
#include <Date.au3>

Global $LogFile, $WsiInstallerPath, $DraftingInstallerPath, $DraftingName, $WsiName, $LicenseCode, $SQLpath, $hQuery, $aRow, $ExitChecker

FileInstall("DraftingInstall.log", @ScriptDir, 1)
$LogFile = (@ScriptDir & "DraftingInstall.log")

; Note the admin rights status
If IsAdmin() <> 1 Then
FileOpen($LogFile)
FileWrite($LogFile, _NowDate() & " " & _NowTime() & ": The installer did not detect admin rights for this user." & @CRLF)
FileClose($LogFile)
EndIf

; Find the ini which contains the location of the SQLite file.  The use of an ini file is so that
; when the database location changes, among other things, only the ini needs updated.

If FileExists(@ScriptDir & "Draftingsqliteloc.ini") Then
$SQLpath = IniRead(@ScriptDir & "Draftingsqliteloc.ini", "SQLLocation", "Path", "")
$WsiInstallerPath = IniRead(@ScriptDir & "Draftingsqliteloc.ini", "WSIInstallerLocation", "Path", "")
$WsiName = IniRead(@ScriptDir & "Draftingsqliteloc.ini", "WSIInstallerLocation", "Name", "")
$DraftingInstallerPath = IniRead(@ScriptDir & "Draftingsqliteloc.ini", "DraftingInstallerLocation", "Path", "")
$DraftingName = IniRead(@ScriptDir & "Draftingsqliteloc.ini", "DraftingInstallerLocation", "Name", "")
ConsoleWrite($SQLpath & @LF)
ConsoleWrite($DraftingInstallerPath & @LF)
Else
FileOpen($LogFile)
FileWrite($LogFile, _NowDate() & " " & _NowTime() & ": The Draftingsqliteloc.ini is not in the same directory as the installer." & @CRLF)
FileClose($LogFile)
Exit (1)
EndIf

; Grab the license code assigned to the user in the License DB

_SQLite_Startup()
If @error Then
FileOpen($LogFile)
FileWrite($LogFile, _NowDate() & " " & _NowTime() & ": The code that runs the SQL query failed.  The _SQLite_Startup(" & '"' & "SQLite.dll" & '"' & ") command produced an error." & @CRLF)
FileClose($LogFile)
SetError(0)
EndIf
_SQLite_Open($SQLpath)
Sleep(1000)
_SQLite_Query(-1, 'SELECT Drafting FROM Install WHERE Username="' & @UserName & '";', $hQuery)
ConsoleWrite('SELECT Drafting FROM Install WHERE Username="' & @UserName & '";' & @LF)
If _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK Then
Else
FileOpen($LogFile)
FileWrite($LogFile, _NowDate() & " " & _NowTime() & ": The code that runs the SQL query failed.  The username is missing or is not entered correctly in the correct case.  Error = " & @error & @CRLF)
FileClose($LogFile)
Exit (1)
EndIf
_SQLite_QueryFinalize($hQuery)
_SQLite_Close()
_SQLite_Shutdown()
$LicenseCode = $aRow[0]

I had previously programmed the scrip to exit if @error was set after _SQLite_Startup() was called. I removed the Exit call to see if the script would proceed to the next phases.

EDIT:

So, I figure the problem is in the <sqlite.dll.au3> file. I dropped the sqlite.dll file into the script directory and changed the script so that it reads _SQLite_Startup(@ScriptDir & "sqlite.dll"). This caused the script to work on one of the computers that wouldn't execute. Interestingly enough, using FileInstall("sqlite.dll", @ScriptDir, 1) doesn't work. It doesn't unpack the sqlite.dll file upon execution, I have to manually copy to file into the executing directory (I use c:Temp). And yea, the file was in the same directory as the script when I was compiling.

Edited by Colyn1337

Share this post


Link to post
Share on other sites



your FileInstall statement is wrong, you must do it like this FileInstall("sqlite.dll", @ScriptDir & "sqlite.dll", 1)

Share this post


Link to post
Share on other sites

Just a note about that: since you're deploying apps using SQLite, you ought to only FileInstall the DLL. This is because the latest version of the SQLite3.dll.au3 doesn't contain both x86 and x64 versions of the DLL but will try to download the correct version from AutoIt repository.

Relying to download in deployment is going to put useless heavy load on AutoIt server and slown down things at your end as well (and hit enterprise firewall in many cases).


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

your FileInstall statement is wrong, you must do it like this FileInstall("sqlite.dll", @ScriptDir & "sqlite.dll", 1)

Actually, I was missing the "". It works if you do FileInstall("sqlite.dll", @scriptdir & "", 1). The @scriptdir doesn't end in a "" to indicate a directory to the functions. Usually I declare my temp directory ahead and use a variable like so:

$Test = (@ScriptDir & "")
FileInstall("test.txt", $Test, 1)
Exit

The bummer is, that still doesn't explain why the _sqlite_startup() doesn't work consistently across computers.... The helpfile states "If SQLite.dll.au3 is included the dll will be created in @SystemDir." It also indicates the function looks in the @systemdir or the @scriptdir where I have the file manually. It's like it cannot find it, which is odd.

I do appreciate you pointing out the error tho, I'd have been scratching my head on that one for awhile.

Edited by Colyn1337

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Just a note about that: since you're deploying apps using SQLite, you ought to only FileInstall the DLL. This is because the latest version of the SQLite3.dll.au3 doesn't contain both x86 and x64 versions of the DLL but will try to download the correct version from AutoIt repository.

Relying to download in deployment is going to put useless heavy load on AutoIt server and slown down things at your end as well (and hit enterprise firewall in many cases).

That explains everything.... Do you happen to have the links to those (on hand of course)? I can tell my script to unpack the right one depending on os architecture.

EDIT: I mean to say that I can then download them and FileInstall() to lessen the wear on the server.

Edited by Colyn1337

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You can find the link in SQLite.dll.au3. Here it is:

http://www.autoitscript.com/autoit3/files/beta/autoit/archive/sqlite/

The most recent versions are those without a date version in the name.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Thanks for holding the bar ProgAndy ;)


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Gentlemen, I thought you'd like to know that thanks to your assistance the problem is now resolved. My custom installer does not fail at the _sqlite_startup()... Or at all for that matter. Thanks again!

Share this post


Link to post
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
Sign in to follow this  
Followers 0