questions manage dbf

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

Re: questions manage dbf

Post by Silvio.Falconi »

should I use tdatabase or mysql or ads?
I do not have to manage large archives for which it is necessary in my opinion mysql or ads, now I have the only need to use archives that I can open from another part because I explain you I created a function that sends messages on Telegram, to inform teachers of the school, and this function ( on a application) is always active because at a time interval it reads the requests on telegram and responds automatically, so it needs to read information from two archives that could be used by the same application by an operator in an office.
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: questions manage dbf

Post by James Bott »

I agree, you do not need to use SQL for small workgroups. I suggest that you start with TDatabase then you may want to upgrade to my TData class. TData adds some features like automatic sequential IDs and reuse of deleted records.

I will put together some sample code to get you started.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: questions manage dbf

Post by James Bott »

OK, here is a sample program showing how easy it is to create and use database objects. We are not using TDatabase directly, but rather creating a customer class which inherits from TDatabase. Later I will show you how to create multiple database objects that eliminate repetitive code. -James

Code: Select all

/*
Purpose  : Sample OOP using TDatabase
Program  : Test05.prg
Author   : James Bott, jbott@compuserve.com
Date     : 10/04/2018 04:49:55 PM
Company  : Intellitech
Copyright: Copyright © 2017 Intellitech. All rights reserved.
Language : Fivewin/xHarbour
Updated  : 
Notes    : Use the customer.dbf in the FWH\samples directory

*/

#include "fivewin.ch"


Function Main()
   Local oCustomer

   // Houekeeping
   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )
   SET EXCLUSIVE OFF
   SET(_SET_AUTOPEN, .T. )
   SET default to ".\"
   
   // Opens the dbf shared
   // New workarea is automaticlly selected
   // Loads all fields of the first record into an array
   // _/gather routines needed
   oCustomer:= TCustomer():New()
   
   msgInfo(oCustomer:First)  
   
   // Replace the data in the array for this field
   oCustomer:First := "Silvio"
   
   // lock record, save buffer, and unlock   
   // oCustomer:save()
   
   msgInfo(oCustomer:First)
   oCustomer:skip()
   msgInfo(oCustomer:First)
   
   oCustomer:end() 

Return nil

//---------------------------------------------------------------------------//

CLASS TCustomer from TDatabase
   Method New()
Endclass

Method New() CLASS TCustomer
   Super:New(,"customer","DBFCDX",.t.)
   ::use()
   // Note: Since you are using DBFCDX, the index file is automatically opened
   // and the first index is selected and it is at the first record.
Return self

//---------------------------------------------------------------------------//

// EOF 
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Post Reply