FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour perhaps error on tdatabase - resolved
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
perhaps error on tdatabase - resolved
Posted: 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



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 (fw): Select all Collapse
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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: perhaps error on tdatabase
Posted: 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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: perhaps error on tdatabase
Posted: Mon Apr 05, 2021 01:01 PM
::oRooms := TDatabase():Open( nil, cDir+"ROOMS", "DBFCDX", .t. )
::SetOrder( "rooms_id" )
::GoTop()

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


but I'm thinking on a function I use another alias of oRooms to give the total
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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 March-April 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: perhaps error on tdatabase
Posted: Mon Apr 05, 2021 03:49 PM

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

Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: perhaps error on tdatabase
Posted: Mon Apr 05, 2021 04: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 March-April 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: perhaps error on tdatabase - resolved
Posted: Wed May 12, 2021 05: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

Continue the discussion