autoitxp Posted November 24, 2007 Posted November 24, 2007 (edited) hi I have little problem counting records for sqllite db this code is nt displaying any records then 0 why is that ? and other question is wat if i want to execute this_SQlite_Query(-1, "select count(*) from " & " " & $mytable & " " & ";" ,$hQuerys)again and again is it slow down performance if Yes then wat method is better to execute query countiniously kindly help and i donno about wat exactly _SQLite_QueryFinalize and _SQLite_QueryFinalize do.func _count()_SQLite_Startup ()_SQLite_Open ($mydb) _SQlite_Query(-1, "select count(*) from " & " " & $mytable & " " & ";" ,$hQuerys) _SQLite_FetchData ($hQuerys, $sOut) _GUICtrlStatusBarSetText($StatusBar , Number($sOut))_SQLite_Close ($mydb)_SQLite_Shutdown ()EndFunc Edited November 24, 2007 by autoitxp
Bowmore Posted November 24, 2007 Posted November 24, 2007 hi I have little problem counting records for sqllite db this code is nt displaying any records then 0 why is that ? and other question is wat if i want to execute this again and again is it slow down performance if Yes then wat method is better to execute query countiniously kindly help and i donno about wat exactly do. The data returned by _SQLite_FetchData ($hQuerys, $sOut) is an array even if there can only be one value returned by count(*). When accessing an array without an index it always equates to "" in AutoIt. Therefore Number("") = 0. Try Number($sOut[0]) func _count() _SQLite_Startup () _SQLite_Open ($mydb) _SQlite_Query(-1, "select count(*) from " & " " & $mytable & " " & ";" ,$hQuerys) _SQLite_FetchData ($hQuerys, $sOut) _GUICtrlStatusBarSetText($StatusBar , Number($sOut[0])) _SQLite_Close ($mydb) _SQLite_Shutdown () EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
autoitxp Posted November 24, 2007 Author Posted November 24, 2007 Thanks it works now wat if i execute this function again and again is it effect any bad in my script ? and when and where to use _SQLite_QueryFinalize and _SQLite_QueryFinalize func _count() _SQLite_Startup () _SQLite_Open ($mydb) _SQlite_Query(-1, "select count(*) from " & " " & $mytable & " " & ";" ,$hQuerys) _SQLite_FetchData ($hQuerys, $sOut) _GUICtrlStatusBarSetText($StatusBar , Number($sOut[0])) _SQLite_Close ($mydb) _SQLite_Shutdown () EndFunc
Bowmore Posted November 24, 2007 Posted November 24, 2007 Thanks it works now wat if i execute this function again and again is it effect any bad in my script ? and when and where to use _SQLite_QueryFinalize and _SQLite_QueryFinalize func _count() _SQLite_Startup () _SQLite_Open ($mydb) _SQlite_Query(-1, "select count(*) from " & " " & $mytable & " " & ";" ,$hQuerys) _SQLite_FetchData ($hQuerys, $sOut) _GUICtrlStatusBarSetText($StatusBar , Number($sOut[0])) _SQLite_Close ($mydb) _SQLite_Shutdown () EndFunc It's not clear from what you have posted so far why you need to keep checking the database for the number of records in $mytable? _SQLite_QueryFinalize basically tells SQLite that you do not want to retrive any more data from this query not really neccessary for a select count(*) query. The correct way to use it is func _count _SQLite_Startup () _SQLite_Open ($mydb) _SQlite_Query(-1, "select count(*) from " & " " & $mytable & " " & ";" ,$hQuerys) _SQLite_FetchData ($hQuerys, $sOut) _GUICtrlStatusBarSetText($StatusBar , Number($sOut[0])) _SQLite_QueryFinalize _SQLite_Close ($mydb) _SQLite_Shutdown () EndFuncoÝ÷ Øò¢æ«yÆ¥)යw-Ü¢éí©ò¶)²)ò¢êìr¸©¶+pY[z«¢rG«ü¨º^Ø^u«Zm«¢wjÛazËZ®Úʬr¸©µ©ÝrZ,z+péò¢èZ½çâ+!yÜ"¶ÞÅ©©æ®¶sbõ5ÆFUõ7F'GW¢õ5ÆFUô÷Vâb33c¶×F" ¢vÆRb33c·6ö×Fæu÷FõöFð¢´Fò7GVf`¢²ââà ¢ö6÷VçB²F7Æ&V6÷&B6÷VçBâ7FGW2&" ¢´FòÖ÷&R7GVf`¢²ââà ¢tVæ@ ¢õ5ÆFUô6Æ÷6Rb33c¶×F"¢õ5ÆFUõ6WFF÷vâ ¤W@ ¦gVæ2ö6÷Vç@ õ5ÆFUõVW'ÓÂgV÷C·6VÆV7B6÷VçB¢g&öÒgV÷C²fײgV÷C²gV÷C²fײb33c¶×F&ÆRfײgV÷C²gV÷C²fײgV÷C³²gV÷C²Âb33c¶VW'2 õ5ÆFUôfWF6FFb33c¶VW'2Âb33c·4÷WB ôuT7G&Å7FGW4&%6WEFWBb33cµ7FGW4&"ÂçVÖ&W"b33c·4÷WE³Ò¢õ5ÆFUõVW'fæÆ¦P¤VæDgVæ "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
Hoox Posted December 5, 2007 Posted December 5, 2007 Sorry if I hijack this thread, but I want to do something similar. I tryed to modify the script from Bowmore, but I can't get it to work What I want to do is get the number of records to a variable. This is what I want: $Count = _SQLite_Exec (-1, "Select count(*) from wai_data where Hostname='"&@Computername&"';") And I want output like $Count = 8 Why is this so hard?
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