Jochem Posted October 25, 2011 Share Posted October 25, 2011 (edited) #include <_SQLite_easy.au3> Local $aResult, $iRows, $iColumns, $iRval, $hQuery, $aNames, $aRow, $sMsg, $hQuery1, $aRow1, $sMsg1 local $cI_CompName = @ComputerName, $APP = "name" $handle = sqlite_connect (".\sql\admin") _SQlite_Query (-1, "SELECT '" & $APP & "' FROM INVENTORY WHERE computer = '" & $cI_CompName & "';", $hQuery) While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK $sMsg &= $aRow[0] ConsoleWrite($sMsg & @CRLF) WEnd _SQlite_Query (-1, "SELECT name FROM INVENTORY WHERE computer = '" & $cI_CompName & "';", $hQuery1) While _SQLite_FetchData ($hQuery1, $aRow1) = $SQLITE_OK $sMsg1 &= $aRow1[0] ConsoleWrite($sMsg1 & @CRLF) WEnd sqlite_end() I have two querys who should be the same but, with the first query the result is "name" the second query is giving me the database cell: "name 2013" Edited October 25, 2011 by Jochem Link to comment Share on other sites More sharing options...
jchd Posted October 25, 2011 Share Posted October 25, 2011 When you quote a string, it becomes an SQL litteral, thus SELECT 'name' from ... will return the litteral 'name'. Nothing very surprising. The second query SELECT name from ... should work better indeed. Why don't you use the standard UDF with easy to use functions? 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...
Jochem Posted October 25, 2011 Author Share Posted October 25, 2011 Why don't you use the standard UDF with easy to use functions? the _SQLite_easy is also calling the standard udf. Link to comment Share on other sites More sharing options...
Jochem Posted October 25, 2011 Author Share Posted October 25, 2011 When you quote a string, it becomes an SQL litteral, thus SELECT 'name' from ... will return the litteral 'name'. Nothing very surprising.The second query SELECT name from ... should work better indeed. Why don't you use the standard UDF with easy to use functions? indeed without quotes it works, thanks Link to comment Share on other sites More sharing options...
jchd Posted October 25, 2011 Share Posted October 25, 2011 the _SQLite_easy is also calling the standard udf.Correct but why it is easier is beyond me. With your code you concatenate all columns of all rows returned, if any. If none are returned, your output still contains what was left by the previous query. You should avoid concatenating string litterals without escaping them (see _SQLite-Escape, or better _SQLite_Fast_Escape of the last beta). BTW if ever you need to quote schema names, (containing spaces or special characters for instance), use either square brackets [this is the name of my 'table'] or double quotes "this is the name of my 'table'" 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...
Jochem Posted October 26, 2011 Author Share Posted October 26, 2011 Oke I see, in that case I will change it to the standaard udf. thanks for your explanation 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