Page 2 of 6

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 2:22 pm
by James Bott
Diego,

Thanks for contributing. It seems I need to look at xBrowse.

James

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 2:36 pm
by Diego Decandia
James,
I have an application where the problem occurs, but when I try to extract an example that presents the problem, the problem is not there. As soon as possible, i will place a test.

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 4:41 pm
by Diego Decandia
Ok, this is the example to test.
Dialog 1 has a TDatabase object in the browse, dialogue 2 uses a DBF directly, but the essential thing is the btmbmp with oDBF:Gotop() and oDBF:Gobottom().
Without the action of the Btnbmp (which contain oDBF:GoTop() or oDBF:GoBottom()) Everything is ok even with fwh 17.07

Code: Select all  Expand view
// ---------------------------------------------//
function TEST
    local oDlg

    DEFINE DIALOG oDlg PIXEL SIZE 200,200 TITLE "Test"

    @ 10, 10 BUTTON "DIALOG 1" OF oDlg PIXEL SIZE 35,15 ACTION DLG1()
    @ 40, 10 BUTTON "DIALOG 2" OF oDlg PIXEL SIZE 35,15 ACTION DLG2()

    ACTIVATE DIALOG oDlg CENTERED
return nil

function DLG1
    local oDlg, oBrw, oDBF

    USE C:\FWH\SAMPLES\CUSTOMER NEW
    INDEX ON FIELD->FIRST TAG FIRST
    INDEX ON FIELD->LAST TAG LAST
    CLOSE CUSTOMER

    oDBF := TDATABASE():Open( nil,"C:\FWH\SAMPLES\CUSTOMER", "DBFCDX" )
    oDBF:SetOrder( "FIRST" )

    DEFINE DIALOG oDlg PIXEL SIZE 600,495 TITLE "DLG1"

   @ 0,0 XBROWSE oBrw SIZE -50,-2 PIXEL OF oDlg ;
    ALIAS ( oDBF:cALIAS ) CELL LINES NOBORDER AUTOSORT AUTOCOLS ;

   oBrw:CreateFromCode()

   @ 10, 250 BtnBmp of oDlg RESOURCE "CLOSE16" ;
    PIXEL TOP NOBORDER 2007 SIZE 35,25 ;
    PROMPT "&E n d" ACTION oDlg:End()

    @ 45, 250 BTNBMP OF oDlg PROMPT "First" ;
        SIZE 35,25 RESOURCE "GOTOP16" PIXEL TOP NOBORDER 2007 ;
        ACTION ( oDBF:GOTOP(), oBrw:Refresh(), oBrw:SetFocus() )

    @ 80, 250 BTNBMP OF oDlg PROMPT "Last" ;
        SIZE 35,25 RESOURCE "GOBOT16" PIXEL TOP NOBORDER 2007 ;
        ACTION ( oDBF:GOBOTTOM(), oBrw:Refresh(), oBrw:SetFocus() )

    ACTIVATE DIALOG oDlg CENTER

    oDBF:End()

return nil

function DLG2
    local oDlg, oBrw

    USE C:\FWH\SAMPLES\CLIENTS NEW
    INDEX ON FIELD->NAME TAG NAME
    INDEX ON FIELD->ADRESS TAG ADRESS
    SET TAG TO NAME
    GO TOP

    DEFINE DIALOG oDlg PIXEL SIZE 600,495 TITLE "DLG2"

   @ 0,0 XBROWSE oBrw SIZE -5,-2 PIXEL OF oDlg ;
    ALIAS ( "CLIENTS" ) CELL LINES NOBORDER AUTOSORT AUTOCOLS ;

   oBrw:CreateFromCode()

    ACTIVATE DIALOG oDlg CENTER

    CLOSE CLIENTS

return nil
 

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 4:51 pm
by norberto
Hi,

Error happens in Twbrowse too.

thanks

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 5:18 pm
by James Bott
Diego,

You forgot to set the default RDD:

REQUEST DBFCDX
rddsetdefault( "DBFCDX" )

If you add those lines it works fine.

James

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 5:32 pm
by Diego Decandia
Hmmm, I have tested into another my application where those set are present...

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 5:41 pm
by Diego Decandia
I confirm that, even by performing the only TEST function with the sets indicated by James, the problem arises. You must open dialog 1, close it, open dialog 2 and, when closed, here is the error.

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 5:44 pm
by James Bott
Diego,

I had to make a few changes to get your sample working (commented lines were erroring out). It was also set to use TDatabase() not TData() which I changed.

I am not seeing any errors using this code.

James

Code: Select all  Expand view
/*
Language : Fivewin/xHarbour
Updated  :
Notes    : Code provided by Diego Decandia
viewtopic.php?f=3&t=34468&p=204989#p204985

*/


#include "fivewin.ch"

Function Main()
   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )
   
   Test()

Return nil

// ---------------------------------------------//
function TEST
    local oDlg

    DEFINE DIALOG oDlg PIXEL SIZE 200,200 TITLE "Test"

    @ 10, 10 BUTTON "DIALOG 1" OF oDlg PIXEL SIZE 35,15 ACTION DLG1()
    @ 40, 10 BUTTON "DIALOG 2" OF oDlg PIXEL SIZE 35,15 ACTION DLG2()

    ACTIVATE DIALOG oDlg CENTERED
return nil

function DLG1
    local oDlg, oBrw, oDBF

    USE C:\FWH\SAMPLES\CUSTOMER NEW
    INDEX ON FIELD->FIRST TAG FIRST
    INDEX ON FIELD->LAST TAG LAST
    CLOSE CUSTOMER
   
    oDBF := TDATA():New( nil,"C:\FWH\SAMPLES\CUSTOMER", "DBFCDX" )
    oDBF:use()
       
    msgInfo(if(oDBF:used(),"Customer.dbf is open","Customer.dbf is not open"))
   
    //oDBF:SetOrder( "FIRST" )
   
    DEFINE DIALOG oDlg PIXEL SIZE 600,495 TITLE "DLG1"

   @ 0,0 XBROWSE oBrw SIZE -50,-2 PIXEL OF oDlg ;
    ALIAS ( oDBF:cALIAS ) CELL LINES NOBORDER AUTOSORT AUTOCOLS ;

   oBrw:CreateFromCode()

   @ 10, 250 BtnBmp of oDlg RESOURCE "CLOSE16" ;
    PIXEL TOP NOBORDER 2007 SIZE 35,25 ;
    PROMPT "&E n d" ACTION oDlg:End()

    @ 45, 250 BTNBMP OF oDlg PROMPT "First" ;
        SIZE 35,25 RESOURCE "GOTOP16" PIXEL TOP NOBORDER 2007 ;
        ACTION ( oDBF:GOTOP(), oBrw:Refresh(), oBrw:SetFocus() )

    @ 80, 250 BTNBMP OF oDlg PROMPT "Last" ;
        SIZE 35,25 RESOURCE "GOBOT16" PIXEL TOP NOBORDER 2007 ;
        ACTION ( oDBF:GOBOTTOM(), oBrw:Refresh(), oBrw:SetFocus() )

    ACTIVATE DIALOG oDlg CENTER

    oDBF:End()

return nil

function DLG2
    local oDlg, oBrw

    USE C:\FWH\SAMPLES\CLIENTS NEW
    INDEX ON FIELD->NAME TAG NAME
    INDEX ON FIELD->ADRESS TAG ADRESS
    //SET TAG TO NAME
    GO TOP

    DEFINE DIALOG oDlg PIXEL SIZE 600,495 TITLE "DLG2"

   @ 0,0 XBROWSE oBrw SIZE -5,-2 PIXEL OF oDlg ;
    ALIAS ( "CLIENTS" ) CELL LINES NOBORDER AUTOSORT AUTOCOLS ;

   oBrw:CreateFromCode()

    ACTIVATE DIALOG oDlg CENTER

    //CLOSE CLIENTS
    use

return nil

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 5:47 pm
by James Bott
Diego,

You must open dialog 1, close it, open dialog 2 and, when closed, here is the error.


Apparently, the syntax:

CLOSE CLIENTS is not valid. If you change it to just USE then it works fine. Try the test code in my previous message.

James

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 5:55 pm
by Diego Decandia
It is true, even putting close all, no error. So it is not good to use <close ' Alias '>.??

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 6:21 pm
by Diego Decandia
In any way, if I use DLG2 first, close clients works.

If I use DLG1 and then DLG2, close clients does not work.

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 8:32 pm
by Enrico Maria Giordano
James Bott wrote:CLOSE CLIENTS is not valid.


CLOSE <alias> is perfectly valid. The problem has to be elsewhere.

EMG

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 9:30 pm
by James Bott
Enrico,

Thanks for the clarification--I should have looked it up. I had never used that syntax before. And when I changed it to USE it started working fine.

It is rather irrelevant in this situation because we are trying to track down an error occurring with TDatabase/TData so using standard database syntax clouds the issue.

James

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 9:38 pm
by Diego Decandia
If in dialog 2, before close clients, you put
MsgInfo (Alias ())
You see that the DBF file is already closed.
Who closed it?

Re: Database - 17.07 - Problems

PostPosted: Fri Aug 25, 2017 9:58 pm
by James Bott
Diego,

I am not seeing that but I am using FWH 16.02 with TDatabase from 17.07 and xHarbour

I assume you are using 17.07? If so, then there must be a problem that is not in the TDatabase class. It could even be a xHarbour or Harbour issue.

James