New topic: How is Nilobject checking possible here?
<http://forums.realsoftware.com/viewtopic.php?t=47010> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message JohnV Post subject: How is Nilobject checking possible here?Posted: Wed Feb 20, 2013 6:21 pm Joined: Sun Jan 28, 2007 2:38 pm Posts: 174 The debugger tells me there is one record. But rs.field("Class") = nil! The problem Is Im trying to catch the NIL, but the line that ask is rs=nil is where the nil is! Can anyone shed any light here? dim rs as recordset dim stmt as string stmt="'SELECT DISTINCT Class FROM Products WHERE Store = '33'" rs=Session.DB.SQLSelect(stmt) if rs= nil or Session.DB.Error then //<---Throws NilObjectExcption here //Handle the error else //Do the work end if Top npalardy Post subject: Re: How is Nilobject checking possible here?Posted: Wed Feb 20, 2013 7:15 pm Real Software Engineer Joined: Sat Dec 24, 2005 8:18 pm Posts: 7730 Location: Canada, Alberta, Near Red Deer JohnV wrote:The debugger tells me there is one record. But rs.field("Class") = nil! The problem Is Im trying to catch the NIL, but the line that ask is rs=nil is where the nil is! Can anyone shed any light here? dim rs as recordset dim stmt as string stmt="'SELECT DISTINCT Class FROM Products WHERE Store = '33'" rs=Session.DB.SQLSelect(stmt) if rs= nil or Session.DB.Error then //<---Throws NilObjectExcption here //Handle the error else //Do the work end if You have a sql error your ignoring Note that your query has a leading single quote in front of the "SELECT" which probably results in an error That still doesn't quite explain the NOE though as rs = nil should be true Is RS in fact nil ? _________________ Norman Palardy (Real Software) ââââââââââââââââââââââââââââââââââââââââââââââââââ Real Studio Developer Conference - April 23 - 26, 2013 http://www.realsoftware.com/community/realworld.php Top JohnV Post subject: Re: How is Nilobject checking possible here?Posted: Wed Feb 20, 2013 9:32 pm Joined: Sun Jan 28, 2007 2:38 pm Posts: 174 Actually the SQL here does have a typo. The original SQL was not "Cut and Pasted" into the window as it is too cryptic to read easily. I tested the actual SQL statement a number of ways both from inside Real Studio and in SQL utilities. The SQL Is fine (Heck it returns one record!: ANd so says the debugger) I'm just sloppy posting a simplified version here. The base question remains: How is it possible to have an nilObjectexection on that line? Does Session.DB.Error refer to t he error thrown when rs=Session.DB.SQLSelect(stmt) was called or does it in fact do a "test" of the DB? Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
