questions manage dbf

Re: questions manage dbf

Postby Silvio.Falconi » Thu Oct 04, 2018 4:05 pm

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.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6867
Joined: Thu Oct 18, 2012 7:17 pm

Re: questions manage dbf

Postby James Bott » Thu Oct 04, 2018 6:05 pm

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: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: questions manage dbf

Postby James Bott » Fri Oct 05, 2018 12:02 am

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  Expand view
/*
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
   // No scatter/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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 136 guests