Recently added routine that included a call to Session.NewSession. Was generating a "No Table is Open in current work area" error when using SQL data. I ended up adding the SELECT command shown below to wwSession.prg. Maybe there's a use case that would get around this without modifying the framework code, but this is seeming to work:
IF !ISNULL(THIS.oRequest)
lcBrowser=THIS.oRequest.GetBrowser()
lcIP=THIS.oRequest.GetIPAddress()
ELSE
STORE "" TO lcBrowser,lcIP
ENDIF
SELECT ('wwsession') && << Added this line
*** Create a new emtpy object
SCATTER NAME THIS.oData MEMO BLANK
WITH THIS.oData
.SessionId = lcSessionid
.FirstOn = DATETIME()
.Laston = DATETIME()
.UserId = lcUserid
.Browser = lcBrowser
.IP = lcIP
.Hits = 1
ENDWITH
Hmmm... interesting that no one has hit this before.
I think the right way to fix this is by fixing the way wwSqlSession::NewSession
works. The problem is that if the table is already open but not selected it fails in the way you see, so we need to make sure that NewSession()
selects the table.
FUNCTION NewSession(lcUserId, lcForcedId)
*** Work around empty 'record' scenario
IF !USED("wwSession")
*** Open the table so we get a cursor at least
this.LocateSession("BLANK") && gives you a blank record and empty cursor
IF !USED("wwSession")
RETURN .F.
ENDIF
ELSE
*** Just in case
SELECT wwSession
ENDIF
RETURN DODEFAULT(lcUserId,lcForcedId)
ENDFUNC
The FoxPro NewSession()
works because it creates an empty cursor via OpenTable()
. But the SQL version does nothing since there's no table to connect to we only pull the data when we need it.
+++ Rick ---