I have done extensive troubleshooting on this issue and am at the point where it makes no sense to me why I am receiving a SQLite "misuse" error when trying to execute a query. I can run the SQL Query manually and it works fine.
I am trying to use the _SQLite_GetTable2d function to return a 2d array from a table in my SQLite database. However, after executing the function, instead of returning $SQLite_OK as it should, I am getting an error code 21 returned (SQLite documentation states this is a "misuse" error. I have done some additional searching on Google, and even tried rebooting my machine thinking the database may be locked after reading some threads... but that does not appear to be the case.
I am properly starting SQLite, Opening the database, Closing the database, & Shutting down SQLite within my function. I am getting the error specifically on the _SQLite_GetTable2d function.
Here is my function:
Func _populateData() ;$magic_data variable is declared globally when the script starts and points to C:\magic_data.db Local $aResult, $iRows, $iColumns, $iRval ;Start SQLite _SQLite_Startup() If @error Then MsgBox(16, "SQLite Error", "SQLite.dll could not be loaded!") Exit -1 EndIf ;open the SQLite database _SQLite_Open($magic_data) If @error Then MsgBox(16, "SQLite Error", "Unable to open database!") Exit -1 EndIf ; Query the Users_Name table $iRval = _SQLite_GetTable2d($magic_data, "SELECT * FROM Users_Name;", $aResult, $iRows, $iColumns) ;Display the returned value for $iRval for troubleshooting error Msgbox(0,"", $iRval) If $iRval = $SQLITE_OK Then _SQLite_Display2DResult($aResult) Else MsgBox(16, "SQLite Error: " & $iRval, _SQLite_ErrMsg()) EndIf ;close the SQLite database _SQLite_Close($magic_data) ;shutdown SQLite _SQLite_Shutdown() EndFunc