Migrating TDatabase to FWH19.03's from FWH11.08

Re: Migrating TDatabase to FWH19.03's from FWH11.08 (Resolved)

Postby hua » Mon May 06, 2019 2:18 am

James Bott wrote:Hua,

Here is a more complete New() method. You can use this as a starting point for each class (one class for each database). The file is opened (with automatic retrys) and then the primary key index is set. So with just this one line of code you open the database, open the indexes, and set the order.

oCustomers:= TCustomers():New()

Sample New() method:

Code: Select all  Expand view  RUN
CLASS TCustomers from TDatabase
   Method New()
ENDCLASS

Method New( lShared ) Class TCustomers
   Default lShared:= .T.
   ::Super:New(,"customers",,lShared)
   If ::Use()
      ::SetOrder("CUSTNO") // Primary key
      ::Gotop()
   Endif
Return self
 


Note that at the start of your application you need to do this (assuming you are using CDX's):

Code: Select all  Expand view  RUN
 
   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )
   SET EXCLUSIVE OFF
   SET(_SET_AUTOPEN, .T. )
 

This causes all the indexes to be automatically opened whenever you open a DBF.


Thanks James! It could serve as a template for new projects
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests