To James Bott - Error Using TData

User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

To James Bott - Error Using TData

Post by Silvio.Falconi »

this simple program fails with runtime error

Image

Code: Select all

#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oCust

   oCust := TData():New( , "C:\FWH\SAMPLES\CUSTOMER", "DBFCDX", .t. )
   oCust:use()

   if oCust:used()
      oCust:first := Upper( oCust:First )
      oCust:Save()
   else
      ? "file not used"
   endif

return nil
log

Code: Select all

Application
===========
   Path and name: C:\Work\Errori\test_tdata\test.Exe (32 bits)
   Size: 3,909,120 bytes
   Compiler version: Harbour 3.2.0dev (r1703231115)
   FiveWin  version: FWH 19.03
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.2, Build 9200 

   Time from start: 0 hours 0 mins 0 secs 
   Error occurred at: 05/27/19, 11:50:57
   Error description: Error DBFCDX/1020  Data type error: ID

Stack Calls
===========
   Called from:  => FIELDPUT( 0 )
   Called from: C:\Work\Lib32\tdata\TData.prg => TDATA:SAVEDATA( 505 )
   Called from: C:\Work\Lib32\tdata\TData.prg => TDATA:SAVE( 463 )
   Called from: test.prg => MAIN( 15 )

System
======
   CPU type: Intel(R) Atom(TM) x5-Z8350  CPU @ 1.44GHz 1440 Mhz
   Hardware memory: 3961 megs

   Free System resources: 90 %
        GDI    resources: 90 %
        User   resources: 90 %

   Windows total applications running: 3
      1 , C:\Work\Errori\test_tdata\test.Exe                                                                  
      2 G,                                                                                                     
      3 G, C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.15063.1324_none_b95cd17f98b8af 

Variables in use
================
   Procedure     Type   Value
   ==========================
   FIELDPUT
     Param   1:    O    Class: ERROR
   TDATA:SAVEDATA
     Param   1:    N    1
     Param   2:    N    1
     Local   1:    U    
     Local   2:    U    
   TDATA:SAVE
     Local   1:    N    1
     Local   2:    C    ""
     Local   3:    N    1
   MAIN
     Local   1:    L    .T.
     Local   2:    L    .F.

Linked RDDs
===========
   DBF
   DBFFPT
   DBFBLOB
   DBFCDX
   DBFNTX

DataBases in use
================

  1: => DB001                              RddName: DBFCDX
     ==============================
     RecNo    RecCount    BOF   EOF
          1          500      .F.   .F.

     Indexes in use                        TagName

     Relations in use

Classes in use:
===============
     1 ERROR
     2 HBCLASS
     3 HBOBJECT
     4 TDATABASE
     5 TDATA
     6 TREG32
     7 TSTRUCT

Memory Analysis
===============
      577 Static variables

   Dynamic memory consume:
      Actual  Value:     524288 bytes
      Highest Value:     524288 bytes

 
Last edited by Silvio.Falconi on Mon May 27, 2019 3:53 pm, edited 3 times in total.
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Error Using TData

Post by nageswaragunupudi »

Your sample works fine for me using TDatabase

Code: Select all

#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oCust

   oCust := TDatabase():New( , "C:\FWH\SAMPLES\CUSTOMER", "DBFCDX", .t. )
   oCust:use()

   if oCust:used()
      oCust:first := Upper( oCust:First )
      oCust:Save()
      XBROWSER oCust
   else
      ? "file not used"
   endif

return nil
Image

Can you please try this with TDatabase instead of TData and confirm it is working?
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Error Using TData

Post by Silvio.Falconi »

yes with tdatabase run ok...strange!!
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: To James Bott - Error Using TData

Post by James Bott »

Silvio,

Your example works fine here.

Perhaps you have a corrupted index?
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: To James Bott - Error Using TData

Post by nageswaragunupudi »

Silvio

As Mr. James suggested, you may be having a corrupted index, which works with TDatabase but not TData.
Please delete customer.cdx and then run the program using TData.

For your quick convenience, I make a little addition to your program.

Code: Select all

#include "fivewin.ch"

REQUEST DBFCDX

function Main()

   local oCust

   FERASE( "c:\fwh\samples\customer.cdx" )

   oCust := TData():New( , "C:\FWH\SAMPLES\CUSTOMER", "DBFCDX", .t. )
   oCust:use()

   if oCust:used()
      oCust:first := Upper( oCust:First )
      oCust:Save()
      XBROWSER oCust
   else
      ? "file not used"
   endif

return nil
Please try this code to eliminate the possibility of corrupt index.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: To James Bott - Error Using TData

Post by Silvio.Falconi »

Sorry, same error!!!

Image

THEN I NOT HAVE CORRUPTED INDEX
I use that there is on fwh Folder samples

Code: Select all

Application
===========
   Path and name: C:\Work\Errori\test_tdata\test2.Exe (32 bits)
   Size: 3,909,120 bytes
   Compiler version: Harbour 3.2.0dev (r1703231115)
   FiveWin  version: FWH 19.03
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows version: 6.2, Build 9200 

   Time from start: 0 hours 0 mins 0 secs 
   Error occurred at: 05/27/19, 20:04:25
   Error description: Error DBFCDX/1020  Data type error: ID

Stack Calls
===========
   Called from:  => FIELDPUT( 0 )
   Called from: C:\Work\Lib32\tdata\TData.prg => TDATA:SAVEDATA( 505 )
   Called from: C:\Work\Lib32\tdata\TData.prg => TDATA:SAVE( 463 )
   Called from: TEST2.PRG => MAIN( 16 )

System
======
   CPU type: Intel(R) Atom(TM) x5-Z8350  CPU @ 1.44GHz 1440 Mhz
   Hardware memory: 3961 megs

   Free System resources: 90 %
        GDI    resources: 90 %
        User   resources: 90 %

   Windows total applications running: 3
      1 , C:\Work\Errori\test_tdata\test2.Exe                                                                 
      2 G,                                                                                                     
      3 G, C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.15063.1324_none_b95cd17f98b8af 

Variables in use
================
   Procedure     Type   Value
   ==========================
   FIELDPUT
     Param   1:    O    Class: ERROR
   TDATA:SAVEDATA
     Param   1:    N    1
     Param   2:    N    1
     Local   1:    U    
     Local   2:    U    
   TDATA:SAVE
     Local   1:    N    1
     Local   2:    C    ""
     Local   3:    N    1
   MAIN
     Local   1:    L    .T.
     Local   2:    L    .F.

Linked RDDs
===========
   DBF
   DBFFPT
   DBFBLOB
   DBFCDX
   DBFNTX

DataBases in use
================

  1: => DB001                              RddName: DBFCDX
     ==============================
     RecNo    RecCount    BOF   EOF
          1          500      .F.   .F.

     Indexes in use                        TagName

     Relations in use

Classes in use:
===============
     1 ERROR
     2 HBCLASS
     3 HBOBJECT
     4 TDATABASE
     5 TDATA
     6 TREG32
     7 TSTRUCT

Memory Analysis
===============
      577 Static variables

   Dynamic memory consume:
      Actual  Value:     524288 bytes
      Highest Value:     524288 bytes
Last edited by Silvio.Falconi on Mon May 27, 2019 6:09 pm, edited 1 time in total.
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: To James Bott - Error Using TData

Post by karinha »

Alert( "Arquivo: " + Dbf() + " Indice:" + Str( IndexOrd() ) )
João Santos - São Paulo - Brasil
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: To James Bott - Error Using TData

Post by Silvio.Falconi »

I add the alert of Jao

Image
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: To James Bott - Error Using TData

Post by nageswaragunupudi »

Mr. James

Are you using the customer.dbf in \fwh\samples\ folder? if so, which version of FWH? Does the customer.dbf you are using have the field "ID" ?

Please see this part of the error.log

Code: Select all

   Error description: Error DBFCDX/1020  Data type error: ID

Stack Calls
===========
   Called from:  => FIELDPUT( 0 )
   Called from: C:\Work\Lib32\tdata\TData.prg => TDATA:SAVEDATA( 505 )
   Called from: C:\Work\Lib32\tdata\TData.prg => TDATA:SAVE( 463 )
   Called from: test.prg => MAIN( 15 )
 
It is clear from the error.log that TData's SAVEDATA method tried to write some data to the field ID using the function FIELDPUT().

ID is a readonly field and data can not be written to this field. That is the reason why FIELDPUT() resulted in a runtime error.

It is obvious that this has nothing to do with index.

Looks like TData's method SaveData() does not check if a field is readonly or not before saving data to the field, whereas TDatabase considers whether a field is readonly or not.

This must the reason why the Save() method of the parent class TDatabase works correctly but the enhanced methods Save() and SaveData() of TData fail.

May be you need to consider updating TData to handle the latest field types or consider to use parent class methods of TDatabase, without over-riding them.
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: To James Bott - Error Using TData

Post by Silvio.Falconi »

Nages,
Now EmagDbu of Enrico Maria read the new field as you can see here
I open the customer.dbf and the indices into c:\fwh\samples

Image

as you can see it open the index and the index is not corrupted!!!!
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: To James Bott - Error Using TData

Post by James Bott »

Nages,

Yes you are correct. I have never used an autoincrementing field type in an app, so I never noticed this issue. I will look into it.

However, Silvio is not planning to use autoincrementing field types, so I it won't be an issue for him.

I guess I wasn't clear about the index. I didn't mean that because it had an index, I meant that the only other thing I could think of, was that the index was corrupted and thus when trying to save the ID field, which then updates the index, this was generating an error.

This was before you pointed out the fieldtype was autoincrementing and thus read-only.

I will be making a fix for TData to handle read-only fields.

James
Last edited by James Bott on Mon May 27, 2019 6:43 pm, edited 1 time in total.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: To James Bott - Error Using TData

Post by karinha »

Code: Select all

      DbCreate( "CUSTOMER.DBF", { { "ID",         "ID", 04, 0 }, ;
                                  { "FIRST",      "C", 20,  0 }, ;
                                  { "LAST",       "C", 20,  0 }, ;
                                  { "STREET",     "C", 30,  0 }, ;
                                  { "CITY",       "C", 30,  0 }, ;
                                  { "STATE",      "C", 02,  0 }, ;
                                  { "ZIP",        "C", 10,  0 }, ;
                                  { "HIREDATE",   "D", 08,  0 }, ;
                                  { "MARRIED",    "L", 01,  0 }, ;
                                  { "AGE",        "N", 02,  0 }, ;
                                  { "SALARY",     "N", 09,  2 }, ;
                                  { "NOTES",      "C", 70,  0 } } )
 
João Santos - São Paulo - Brasil
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: To James Bott - Error Using TData

Post by nageswaragunupudi »

Mr. Karinha

Code: Select all

{ { "ID",         "ID", 04, 0 }, ;
 
There is no field type "ID". DBCREATE() ignores "D" from "ID" and creates a field with datatype "I" for Integer
To create Autoincrement field, you need to use datatype "+"
Regards

G. N. Rao.
Hyderabad, India
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: To James Bott - Error Using TData

Post by karinha »

nageswaragunupudi wrote:Mr. Karinha

Code: Select all

{ { "ID",         "ID", 04, 0 }, ;
 
There is no field type "ID". DBCREATE() ignores "D" from "ID" and creates a field with datatype "I" for Integer
To create Autoincrement field, you need to use datatype "+"
Ok, thanks mister Nages.

Regards.
João Santos - São Paulo - Brasil
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: To James Bott - Error Using TData

Post by Silvio.Falconi »

James Bott wrote:Nages,

Yes you are correct. I have never used an autoincrementing field type in an app, so I never noticed this issue. I will look into it.

However, Silvio is not planning to use autoincrementing field types, so I it won't be an issue for him.

I guess I wasn't clear about the index. I didn't mean that because it had an index, I meant that the only other thing I could think of, was that the index was corrupted and thus when trying to save the ID field, which then updates the index, this was generating an error.

This was before you pointed out the fieldtype was autoincrementing and thus read-only.

I will be making a fix for TData to handle read-only fields.

James
James, reviewing the test created by Nages
you can found here http://forums.fivetechsupport.com/viewt ... 80#p221386

my intention was to use the new formats for dbf fields if this solves my problem for the id .

... so if the tdata won't work I won't be able to use it
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply