faustf Posted December 29, 2017 Share Posted December 29, 2017 hi guys , i have a little problem with a select in sqlite 3 , in pratical if i run this Local $aLResult = _Sqlite3_Read(@ScriptDir & "\MaoDb.db", "SELECT * FROM Anagrafica_Arnie WHERE id = 1;") work good and return a row 1 but if i run this $sLNomeArnia= A Local $aLResult = _Sqlite3_Read(@ScriptDir & "\MaoDb.db", "SELECT * FROM Anagrafica_Arnie WHERE Arnia_Name = " & $sLNomeArnia & ";") no such column A but why ??? Func _Sqlite3_Read($sDB, $query_read) Local $hQuery, $sMsg, $aRow, $aResult, $iRows, $iColumns _SQLite_Startup() If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _ "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir, @WorkingDir, @LocalAppDataDir\AutoIt v3\SQLite") EndIf Local $DB = _SQLite_Open($sDB) ;@ScriptDir & "\WEB-SITE\eBay\eBay.db" If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a memory Database!") EndIf $iRval = _SQLite_GetTable(-1, $query_read, $aResult, $iRows, $iColumns) If $iRval = $SQLITE_OK Then Return $aResult Else MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg()) EndIf _SQLite_Close() _SQLite_Shutdown() EndFunc ;==>_Sqlite3_Read thankz at all Link to comment Share on other sites More sharing options...
faustf Posted December 29, 2017 Author Share Posted December 29, 2017 hi guys , i have a little problem with a select in sqlite 3 , in pratical if i run this Local $aLResult = _Sqlite3_Read(@ScriptDir & "\MaoDb.db", "SELECT * FROM Anagrafica_Arnie WHERE id = 1;") work good and return a row 1 but if i run this $sLNomeArnia= A Local $aLResult = _Sqlite3_Read(@ScriptDir & "\MaoDb.db", "SELECT * FROM Anagrafica_Arnie WHERE Arnia_Name = " & $sLNomeArnia & ";") no such column A but why ??? Func _Sqlite3_Read($sDB, $query_read) Local $hQuery, $sMsg, $aRow, $aResult, $iRows, $iColumns _SQLite_Startup() If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _ "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir, @WorkingDir, @LocalAppDataDir\AutoIt v3\SQLite") EndIf Local $DB = _SQLite_Open($sDB) ;@ScriptDir & "\WEB-SITE\eBay\eBay.db" If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a memory Database!") EndIf $iRval = _SQLite_GetTable(-1, $query_read, $aResult, $iRows, $iColumns) If $iRval = $SQLITE_OK Then Return $aResult Else MsgBox($MB_SYSTEMMODAL, "SQLite Error: " & $iRval, _SQLite_ErrMsg()) EndIf _SQLite_Close() _SQLite_Shutdown() EndFunc ;==>_Sqlite3_Read thankz at all Link to comment Share on other sites More sharing options...
jguinch Posted December 29, 2017 Share Posted December 29, 2017 the field "Arnia_Name" seems to be a string, so you have to add quotes : Local $aLResult = _Sqlite3_Read(@ScriptDir & "\MaoDb.db", "SELECT * FROM Anagrafica_Arnie WHERE Arnia_Name = '" & $sLNomeArnia & "';") Also, look at _SQLite_FastEscape faustf 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
faustf Posted December 29, 2017 Author Share Posted December 29, 2017 o yess sorry you have reason thankz again again : ) Link to comment Share on other sites More sharing options...
Earthshine Posted December 30, 2017 Share Posted December 30, 2017 If you have very large tables, select * is the absolute worst thing you can do. It is always better to qualify what columns you want My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
jchd Posted December 30, 2017 Share Posted December 30, 2017 @Earthshine is perfectly right. Always retrieve the only columns you need and if you do require them all, then list them explicitely in the order that best fits processing in your programming language. Why? Simply because if ever you need to reorder, add or remove some column(s) in a table, then all your applications using this table will need rewrite, testing, release, along with a way to cope with old and new designs (think upgrade and backups). Also, double quotes are used in SQL for schema names (databases, tables, views, indices, columns, aliases), while single quotes are used to enclose string values. Earthshine 1 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) 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