ActiveRecord, cubeSQL, & WE == NilObjectException

Ok, I have lost every last hair on my head now…

I am writing a WE (cg-bin) app that uses ActiveRecord (which I have used many times in the past with no issues), with cubeSQL (again used many times in the past with no issue).

when I create a new AR object (serial in this case/example). it creates a new object, and I can set the properties. All is wonderful until I try to save then I get a NilObjectException. right before the object.save, I check to see if the dbase.gDB.isConnected is true. and it comes back true.

if I do the ARGen generated method list (dbase.serial.list) I get a NilObjectException also.

whenever I try to save the new item .save, I get a NilObjectException but the is not nil. And I can do transactions to the dbase without issue.

I must be doing something stupid… err really stupid.

example stack trace that gets dumped to a log file:

BKS_ActiveRecord.Base.Save%%o<BKS_ActiveRecord.Base> dbase.APILogs.!logMe%%sss ccSerialRequest.ccSerialRequest.generateKey%%o<ccSerialRequest.ccSerialRequest>sssssbbs ccSerialRequest.ccSerialRequest.buttonRequest_Action%%o<ccSerialRequest.ccSerialRequest>o<WebButton> Delegate.IM_Invoke%%o<WebButton> AddHandler.Stub.28%% WebButton._ExecuteEvent%b%o<WebButton>sA1v WebControl.!_ExecuteEvent%b%ssA1v WebSession._HandleEvent%%o<WebSession>so<HTTPServer.HTTPRequestContext> WebSession._HandleRequest%i4%o<WebSession>so<HTTPServer.HTTPRequestContext> WebApplication.HandleHTTPRequest%%o<WebApplication>o<HTTPServer.HTTPRequestContext> _CGIGateway.GatewayRequestThread.Event_Run%%o<_CGIGateway.GatewayRequestThread>

so I created a new blank desktop app in R1.1.
copied from the WE app all the ActiveRecord stuff including the dbase. code.
did the same calls/saves and it works from the desktop going to the same exact cubeSQL server. Why would it work in desktop and not WE?

Is there an issue with using AR and connecting to the dbase in App.Open, and have the session(s) use that connection?

sorry for the ramblings. that post was written over the last 36 hours with little sleep in between.

if you need more/clearer info, please let me know.

If you can send me a sample project I will take a look at it. Might be something specific with CubeSQL.

I will send you the code shortly…

oh BTW: the code is very hacky at the moment as I have tried to find the issue with it. so dont hold that against me (too much).

sb

ok I have had time to sit down and figure out what the problem is. User Error. I really dont know WE.

I watched Bob’s videos and found out that I am doing something idiotic. I was doing ActiveRecord like a desktop. I switched to do the way Bob does it in LincShare WE and it works as designed.

Thanks All!!
sb

Thanks, Scott. What were you doing differently that was causing the issue?

I wasnt defining a database property at the app level and session level. just the app level. And then the session was not getting a NIL on the app.db but it was functioning as a NIL. Once I followed your app.db/session.db and using a method on data.db to return which one it should be referencing, it started working like a charm. Then I had to clean up any reference to gDB to be db.

Again thanks Bob for the Videos. It saved me many hairs on my head and I dont have many left.