perhaps error on tdatabase - resolved

perhaps error on tdatabase - resolved

Postby Silvio.Falconi » Mon Apr 05, 2021 10:37 am

Using my application with tdatabase
This error came out, so it is not related to the Tplan class but to the management of archives
I start by using the samplePlan class modified in tdatabase by Nages
the only modification I made is to embed it in the window using a dialog like tfsdi (alanit) and using two tPanels one for the lmenu and one to host the Tplan class.

I did a lot of tests this week without having had any kind of problem

this morning i wanted to try again and i got this error that i can't solve

Image

Error occurred at: 05-04-2021, 12:26:18
   Error description: Error DBCMD/2001  Workarea non in use: DBGOTOP

Stack Calls
===========
   Called from:  => DBGOTOP( 0 )
   Called from: .\source\classes\DATABASE.PRG => (b)TDATABASE( 202 )
   Called from: .\source\classes\DATABASE.PRG => TDATABASE:GOTOP( 0 )
   Called from: source\booking\PBook.prg => SAMPLEPLAN:LOADROOMS( 826 )

LoadRooms method
 
Code: Select all  Expand view
METHOD LoadRooms()  CLASS SamplePlan
       local n
       local cRowName, cRowText
       local oData

       ::oRooms:GoTop()
       ::oPlann:hRows := {=>}

       DO WHILE ! ::oRooms:Eof()
          If AllTrim(::oRooms:TYPE ) == AllTrim( ::cTypeRoom ) ;
             .AND. val(right( ::oRooms:ID,3))  >= ::nNumFrom  ;
             .AND. val(right( ::oRooms:ID,3)) <= ::nNumTo

             ::oPlann:AddRow( ::oRooms:ID, ::oRooms:NAME)

       Endif
          ::oRooms:Skip( 1 )
       ENDDO

    RETURN nil
Last edited by Silvio.Falconi on Tue Apr 06, 2021 10:21 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6893
Joined: Thu Oct 18, 2012 7:17 pm

Re: perhaps error on tdatabase

Postby nageswaragunupudi » Mon Apr 05, 2021 12:35 pm

Error description: Error DBCMD/2001 Workarea non in use: DBGOTOP

You might have closed the alias.

How do you open TDatabase object.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10465
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: perhaps error on tdatabase

Postby Silvio.Falconi » Mon Apr 05, 2021 1:01 pm

::oRooms := TDatabase():Open( nil, cDir+"ROOMS", "DBFCDX", .t. )
::oRooms:SetOrder( "rooms_id" )
::oRooms:GoTop()

::oReserva := TDatabase():Open( nil, cDir+"RESERVA", "DBFCDX", .t. )
::oReserva:SetOrder( "room_in" )
::oReserva:GoTop()


but I'm thinking on a function I use another alias of oRooms to give the total
Code: Select all  Expand view

Function TotaliElementi(cTipo,cDir)
    Local nTotali:= 0
    Local oRoomNumbers
    Local nArea    := Select()

    oRoomNumbers   := TDatabase():Open( nil, cDir+"Rooms",   "DBFCDX", .t. )
    oRoomNumbers:SetOrder( 1 )
    oRoomNumbers:GoTop()

    oRoomNumbers:Exec( < ||
         SET FILTER TO AllTrim( FIELD->TYPE ) == AllTrim( cTipo )
    return nil
    > )
        oRoomNumbers:Gotop()
       nTotali:= oRoomNumbers:OrdKeyCount()
       oRoomNumbers:SetFilter( "" )
       oRoomNumbers:close()

    Select (nArea)
Return  nTotali
 

perhaps this is the problem ?
I must converte also this on a method as

Code: Select all  Expand view
Method  TotaliElementi(cTipo)  CLASS SamplePlan
    Local nTotali:= 0

    ::oRooms:SetOrder( 1 )
    ::oRooms:GoTop()
    ::oRooms:Exec( < ||
         SET FILTER TO AllTrim( FIELD->TYPE ) == AllTrim( cTipo )
    return nil
    > )
        ::oRooms:GoTop()
            nTotali:= ::oRooms:OrdKeyCount()
       ::oRooms:SetFilter( "" )

Return  nTotali
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6893
Joined: Thu Oct 18, 2012 7:17 pm

Re: perhaps error on tdatabase

Postby nageswaragunupudi » Mon Apr 05, 2021 3:49 pm

After
oDbf := TDataBase():Open(...)
check
if oDbf:Used()
? "opened"
else
? "not opened"
endif
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10465
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: perhaps error on tdatabase

Postby Silvio.Falconi » Mon Apr 05, 2021 4:48 pm

nageswaragunupudi wrote:After
oDbf := TDataBase():Open(...)
check
if oDbf:Used()
? "opened"
else
? "not opened"
endif


thanks but the error did not come out

probably because even if I used another area oRoomNumbers of the same archive (room.dbf)
when I went to close oRoomNumbers: close () I also closed :: oRooms otherwise the error is not explained
I changed the function to a method and it seems to be fine
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6893
Joined: Thu Oct 18, 2012 7:17 pm

Re: perhaps error on tdatabase - resolved

Postby James Bott » Wed May 12, 2021 5:07 pm

Silvio,

Whenever you manipulate an open database using either a function or a method you need to save it's state (recno(), filter, index, etc.) and then restore it at the end of the method or function.

However, what I do instead is just open a new copy of the database (even if it is a method of the database class) then do your thing, then close it. This way there is no saving and restoring the state needed.

If you don't do this, you will likely get some strange errors that may not even be repeatable, and they will be very hard to track down.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 28 guests