eternityseeker Posted July 16, 2011 Share Posted July 16, 2011 i have a script where i want to use if function to do something but i don't know how to use it, can anybody help me?here's the code:; $conn is a variable that opens a connection to the database ; $rs is a ADODB Object ;============================= $Query = "Select * from table1" $rs = $conn.Execute ($Query) $array = $rs.GetRows()the problem is that when the $rs variable is empty the script stops.i want to know how to check if this variable is empty and holds no data Link to comment Share on other sites More sharing options...
Andreik Posted July 16, 2011 Share Posted July 16, 2011 If $variable = "" Then ... EndIf When the words fail... music speaks. Link to comment Share on other sites More sharing options...
eternityseeker Posted July 16, 2011 Author Share Posted July 16, 2011 ok i will give it a try now, but can i write: if $rs not = "" then how can i make it continue when it's not null. thank you again Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 (edited) ok i will give it a try now, but can i write: if $rs not = "" then how can i make it continue when it's not null. thank you again i will correct you. If not $rs = "" then or If $rs Then Edited July 16, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Andreik Posted July 16, 2011 Share Posted July 16, 2011 It's most used: If $rs <> "" Then ... EndIf When the words fail... music speaks. Link to comment Share on other sites More sharing options...
eternityseeker Posted July 16, 2011 Author Share Posted July 16, 2011 (edited) thank you for the correction, i tried the previous one but it didn't work for me the script stopped as well, i hope you could bear with me a while here the code i wrote: if $rs = "" Then ShowInfo("Found No Data..", "500", "0") ;show a message using another function Else $array = $rs.GetRows() it stopped at $rs.GetRows() is there any thing else i can try? Edited July 16, 2011 by eternityseeker Link to comment Share on other sites More sharing options...
jchd Posted July 16, 2011 Share Posted July 16, 2011 $rsis a rowset object, not an elementary AutoIt variable. You can test for an empty rowset easily with: $iNumberOfRows = $rs.RecordCount 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...
eternityseeker Posted July 16, 2011 Author Share Posted July 16, 2011 thank you for helping me, i tried it and the : $iNumberOfRows = $rs.RecordCount always gives result = -1 meaning that the "$iNumberOfRows" is equal -1 when $rs is empty and when it is full i'm still trying to find a way to check when it's empty | with your help of course Link to comment Share on other sites More sharing options...
eternityseeker Posted July 16, 2011 Author Share Posted July 16, 2011 i tried the "VarGetType" function as i saw on another topic in the forum, and i found that the variable $rs is an "object" but i didn't find how to check if it's empty on the forum Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 isobj()? Link to comment Share on other sites More sharing options...
eternityseeker Posted July 16, 2011 Author Share Posted July 16, 2011 yes it is an object it passes the "isobj" when it's empty and when it's full do you know how to check if it's empty or holds nothing (for an object) Link to comment Share on other sites More sharing options...
eternityseeker Posted July 16, 2011 Author Share Posted July 16, 2011 I found it ..I found iti found it in another topic, the topic was discussing something bigger than just my case but someone wrote it and i tried it an it worked.here it is:if not $rs.EOF thenthe secret is the "EOF" that was placed after the variable i checks if it's empty.thank you all.i don't know why when i write a dot "." the available parameters aren't shown automatically, i know some of them are shown but not everything.but a great scripting language very very very useful 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