Page 1 of 4

To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 10:09 am
by Silvio.Falconi
this simple program fails with runtime error

Image

Code: Select all  Expand view

#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  Expand view
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

 

Re: Error Using TData

PostPosted: Mon May 27, 2019 10:40 am
by nageswaragunupudi
Your sample works fine for me using TDatabase
Code: Select all  Expand view
#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?

Re: Error Using TData

PostPosted: Mon May 27, 2019 10:49 am
by Silvio.Falconi
yes with tdatabase run ok...strange!!

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 5:30 pm
by James Bott
Silvio,

Your example works fine here.

Perhaps you have a corrupted index?

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 5:50 pm
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  Expand view
#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.

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 6:07 pm
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  Expand view
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


Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 6:08 pm
by karinha
Alert( "Arquivo: " + Dbf() + " Indice:" + Str( IndexOrd() ) )

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 6:12 pm
by Silvio.Falconi
I add the alert of Jao

Image

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 6:16 pm
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  Expand view

   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.

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 6:32 pm
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!!!!

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 6:41 pm
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

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 6:42 pm
by karinha
Code: Select all  Expand view

      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 } } )
 

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 6:55 pm
by nageswaragunupudi
Mr. Karinha

Code: Select all  Expand view

{ { "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 "+"

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 7:20 pm
by karinha
nageswaragunupudi wrote:Mr. Karinha

Code: Select all  Expand view

{ { "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.

Re: To James Bott - Error Using TData

PostPosted: Mon May 27, 2019 7:31 pm
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/viewtopic.php?f=3&t=37080#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