Gorby7 Posted February 14, 2012 Posted February 14, 2012 I'm using 3 easy SQL functions written by Locodarwin found here: They work great, I use the GetRows method to extract the results into a 2D array.The problem comes when there are no records/rows returned. The GetRows method fails with a console output error of "The requested action with this object has failed" and "$aResults=$oResults.GetRows()^ ERROR". I cannot figure out a way to check to see if there no records before calling the GetRows method. I tried using the RecordCount method but it always returns -1 because the recordset is forward-only/read-only. I tried to UBound the results object, but of course that didn't work. Any ideas? Here's my code:$oOpen=_SQLConnect("server","database",1,"sa","password") $oResults=_SQLQuery($oOpen,"EXEC Stored_Procedure_Name") $iColumns=$oResults.Fields.Count MsgBox(0,"","Rows: " & UBound($oResults)) MsgBox(0,"","Rows: " & $oResults.RecordCount) $aResults=$oResults.GetRows() $iIndex=UBound($aResults) _SQLDisconnect($oOpen)
Gorby7 Posted February 14, 2012 Author Posted February 14, 2012 By the way, I'm still on version 3.3.6.1.
jchd Posted February 14, 2012 Posted February 14, 2012 A standard way to avoid hitting this wall if doing something like: If Not $oResults.EOF Then $aResult = $oResults.GetRows() ... EndIf 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)
Gorby7 Posted February 16, 2012 Author Posted February 16, 2012 That works perfectly! I can't believe I didn't think to try something with the EOF property after a whole day of Googling. Thanks a bunch.
jchd Posted February 16, 2012 Posted February 16, 2012 You're welcome; glad it works as expected in your case. 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)
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