lNoVal Posted April 2, 2015 Share Posted April 2, 2015 (edited) Hi Guys, first of all i wanna thank you for this greate forum. I am a autoit newbie and leaned allready a lot (i belive) by reading this forum. Now i got to a strange problem. If i open a FileOpenDialoge befor using my sqlite connection. SQL will not find the DB table. (See first script) But if i comment the FileDialog it works fine and i get the result of my DB Table. Where is the mistake? Thx for your help. #include <Array.au3> #include <SQLite.au3> #include <SQLite.dll.au3> local $sMessage local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\" , "All (*.*)") global $sSQliteDll = _SQLite_Startup("SQLite3.dll") If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _ "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir, @WorkingDir or from www.autoitscript.com") Exit -1 EndIf local $DB_Main_MainDB = _SQLite_Open("Main_DB.db3") Local $hQuery,$aRow local $sql = "SELECT * FROM testscript" _SQLite_Query($DB_Main_MainDB, $sql,$hQuery) dim $test While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK $test = $arow[0] wEnd msgbox (0,0,$test) #include <Array.au3> #include <SQLite.au3> #include <SQLite.dll.au3> local $sMessage ;-------------------------------------------------------------------------------------------- ;local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\" , "All (*.*)") ;----------------------------------------------------------------------------------------- global $sSQliteDll = _SQLite_Startup("SQLite3.dll") If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _ "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir, @WorkingDir or from www.autoitscript.com") Exit -1 EndIf local $DB_Main_MainDB = _SQLite_Open("Main_DB.db3") Local $hQuery,$aRow local $sql = "SELECT * FROM testscript" _SQLite_Query($DB_Main_MainDB, $sql,$hQuery) dim $test While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK $test = $arow[0] wEnd msgbox (0,0,$test) Edited April 2, 2015 by lNoVal Marcelos 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 2, 2015 Moderators Share Posted April 2, 2015 (edited) lNoVal,A successful return from FileOpenDialog resets the @WorkingDir to the path of the returned file. I imagine that the _SQLite_Open cannot then find the database file as it is looking in the wrong place. >Try passing the full path, or reset the path with FileChangeDir. M23Edit: And welcome to the AutoIt forums. Edited April 2, 2015 by Melba23 Marcelos 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
lNoVal Posted April 2, 2015 Author Share Posted April 2, 2015 Melba23 your the best Here is the working code if someone has the same Problem.. #include <Array.au3> #include <SQLite.au3> #include <SQLite.dll.au3> Global $glb_MAIN_DBname = @WorkingDir&"\Main_DB.db3" local $sMessage local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\" , "All (*.*)") FileChangeDir(@WorkingDir) global $sSQliteDll = _SQLite_Startup("SQLite3.dll") If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _ "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir, @WorkingDir or from www.autoitscript.com") Exit -1 EndIf ;msgbox(0,0,$glb_MAIN_DBname) local $DB_Main_MainDB = _SQLite_Open($glb_MAIN_DBname) Local $hQuery,$aRow local $sql = "SELECT * FROM amis_testcasescript" _SQLite_Query($DB_Main_MainDB, $sql,$hQuery) dim $test While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK $test = $arow[0] wEnd msgbox (0,0,$test) Marcelos 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 2, 2015 Moderators Share Posted April 2, 2015 lNoVal,This line merely sets the @WorkingDir to its current content and so is completely superfluous: >FileChangeDir(@WorkingDir)What you need to do is something like this: Local $sWorkingDir = @WorkingDir ; Save current WorkingDir in a variable Global $glb_MAIN_DBname = $sWorkingDir & "\Main_DB.db3" local $sMessage local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\" , "All (*.*)") ; WorkingDir will now be changed FileChangeDir($sWorkingDir) ; So reset WorkingDir to the original saved pathAll clear? M23 Marcelos 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now