hname Posted February 18, 2022 Posted February 18, 2022 Hello, This is my first post on Autoit forum. I encounter a error when I select a csv file from FileOpenDialog and convert it to db using _SQLite_Exec. The error code return is 1 if use both functions together. It works if I remove FileOpenDialog and use file directory. The code and sample are attached( test.au3,sample.csv) Anyone can help, please?
jchd Posted February 18, 2022 Posted February 18, 2022 Your code lacks error checkings. You should check @error after every call capable of failing. For instance, if the subdir ...\Repair_Projects\ doesn't exist, your code fails. Also when testing for a row with a given imei, if the row doesn't exist, the result $imeirow is not an array. Yet you test $imeirow[0] without checking first. BTW you don't need to startup/shutdown more than once. Same for open/close the DB. 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 hereRegExp tutorial: enough to get startedPCRE 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)
hname Posted February 18, 2022 Author Posted February 18, 2022 30 minutes ago, jchd said: Your code lacks error checkings. You should check @error after every call capable of failing. For instance, if the subdir ...\Repair_Projects\ doesn't exist, your code fails. Also when testing for a row with a given imei, if the row doesn't exist, the result $imeirow is not an array. Yet you test $imeirow[0] without checking first. BTW you don't need to startup/shutdown more than once. Same for open/close the DB. Thanks. Those you mentioned I can fix later (as it is a sample code). Let assume my code runnable (it actually run if you just set the correct directory). The thing is whenever I use _SQLite_Exec right after FileOpenDialog , the _SQLite_Exec return @error code 1. That's very annoying. It run perfectly if you put $projectFile to the file directly.
jchd Posted February 19, 2022 Posted February 19, 2022 I did run your code but then no error, except that I removed obviously failing lines. Yet there are a large number of open issues or bugs with the code as it is. 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 hereRegExp tutorial: enough to get startedPCRE 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)
hname Posted February 19, 2022 Author Posted February 19, 2022 16 minutes ago, jchd said: I did run your code but then no error, except that I removed obviously failing lines. Yet there are a large number of open issues or bugs with the code as it is. It's weird. I run my code on three different computers and get the same error code. if you don't mind, could you please upload your code. Thank you for your suggestion. Actually, I am not a coder. I just use autoit code to automate my work and it makes my life and everyone in the company I worked for dealing with data and report processing. I am not proud about my code as I know it is clumsy. The things are I can code what I thought in the way I want and the code works well and help reducing time and company running cost. Thank again.
jchd Posted February 19, 2022 Posted February 19, 2022 6 hours ago, hname said: I run my code on three different computers and get the same error code. Instead, run the code you posted above verbatim and look. 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 hereRegExp tutorial: enough to get startedPCRE 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)
hname Posted February 19, 2022 Author Posted February 19, 2022 57 minutes ago, jchd said: Instead, run the code you posted above verbatim and look. I know now why my code led to @error code 1 (Error calling SQLite API 'sqlite3_exec'). I tested three cases: 1. If I run my old code without FileOpenDialog , it works without issue. 2. If I run my old code with FileOpenDialog , it will give @error code 1 (Error calling SQLite API 'sqlite3_exec'). 3. If I put the _SQLite_Startup() before FileOpenDialog , it works without issue. So, I think I found a bug in Autoit Sqlite API. When you put SQLite_Startup() command after FileOpenDialog, it will give rise to SQLite API calling error.
Developers Jos Posted February 19, 2022 Developers Posted February 19, 2022 8 minutes ago, hname said: FileOpenDialog ...changes the workdir, so guess that could be the reason. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
jchd Posted February 19, 2022 Posted February 19, 2022 What @Jos just said (the SQLite.dll isn't found in @WorkingDir), plus you have lines in your code invoking undeclared variables GUICtrlSetData($StatusLabel,"Updating " & $imei) and other nasties (the first line of the .csv is ignored), close to zero error checking, etc. When you post example code, please make sure it's runable in any other environment so we can test without spending time to fix it. 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 hereRegExp tutorial: enough to get startedPCRE 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)
hname Posted February 19, 2022 Author Posted February 19, 2022 1 minute ago, jchd said: What @Jos just said (the SQLite.dll isn't found in @WorkingDir), plus you have lines in your code invoking undeclared variables GUICtrlSetData($StatusLabel,"Updating " & $imei) and other nasties (the first line of the .csv is ignored), close to zero error checking, etc. When you post example code, please make sure it's runable in any other environment so we can test without spending time to fix it. Got it. Do my best next time.
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