dbfs on Network : wich performance method?

dbfs on Network : wich performance method?

Postby Silvio.Falconi » Mon Oct 29, 2018 5:54 pm

Dear friends,

I wish to ask what is the best way to manage archives in a network for an application I need to create.

Until now I have limited myself to open the archives in an exclusive way because I have left the problem of the network.

I have made applications up until now that were needed for me or my friends for personal use.

Now I need to create something but with the archives in a network so that all the operators can interact with the same archives and at the same time

 for example: make an invoice at the same time another user does it

But there are problems because asking friends in the forum and other people who work with fwh.

Some are oriented to use the class tdatabase others instead open archives in a shared way, another friend sent me a very special modified tdatabase class.
 
I really can not figure out which way I can use so even because I would like to fix already from now those props
that I will need for a tomorrow for my next applications so as to use the archives for apps that require the network and for apps that do not they necessarily need to use them in a network
 
In ancient times I used the class of Manuel Esposito (gather / scatter) but I have so many problems for a simple shirting program
and after this bad experience I preferred not to deal with the topic of the network

I would especially like someone to show me which performance method to use according to his personal working experiences,

which class to use if there is a need for a class and to have small examples to try, to open, modify, delete, search, print and save a record

I thank you in advance
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: dbfs on Network : wich performance method?

Postby James Bott » Tue Oct 30, 2018 2:02 am

Silvio,


Here is an example. This is fully network compatible. Open a file object with one line of code. Databases are open in shared mode, buffered, optimistic locking, no dealing with aliases workareas, etc.

Use this with the customer.dbf file you recently sent me and/or change it slightly to work with any database.


Code: Select all  Expand view  RUN
/*
Purpose  : Showing how to build database object classes
           Also shows inheritance from a base class
Program  :
Author   : James Bott, jbott@compuserve.com
Date     : 10/29/2018 11:42:51 AM
Company  : Intellitech
Copyright: Copyright © 2018 Intellitech. All rights reserved.
Language : Fivewin/xHarbour
Updated  :
Notes    :

*/


#include "fivewin.ch"

Function Main()
   Local oCustomers
   Local oInvoices  
 
   REQUEST DBFCDX
   rddsetdefault( "DBFCDX" )
   SET EXCLUSIVE OFF
   SET(_SET_AUTOPEN, .T. )    // Auto open cdx-index files
   
   BuildIndexes()
 
   oCustomers := TCustomers():new()
   
   oCustomers:skip(10)

   msgInfo(oCustomers:last)        // Shows Farley
   
   oCustomers:last := "Farley 2"   // change
   oCustomers:save()               // save
   msgInfo(oCustomers:last)        // Shows "Farley 2"
   
   oCustomers:last := "Farley"
   oCustomers:save()

   select(oCustomers:nArea)
   browse()                         // Shows Farley
 
Return nil


//---------------------------------------------------------------------------//
// Base class for DBF classes
Class TXData from TDatabase
   Method New()
Endclass

Method New(cFile,lShared) CLASS TXData
   Default lShared := .t.
   ::super():New(,cFile,,lShared)
   ::use()
Return self

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

Class TCustomers from TXData
   Method New()
Endclass

Method New(lShared) CLASS TCustomers
   ::super:New("customer", lShared)
Return self


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

Class TInvoice from TXData
   Method New()
Endclass

Method New(lShared) CLASS TInvoice
   ::super:New("Invoice", lShared)
Return self
*/
//---------------------------------------------------------------------------//

Function BuildIndexes()
   use customer
   Index on "id" tag "custno" to customer
   index on "last" tag "last" to customer
   close

 //  use invoice
 //  index on "last" tag "Invno" to invoice
 //  close
RETURN NIL
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: dbfs on Network : wich performance method?

Postby Silvio.Falconi » Tue Oct 30, 2018 8:14 am

James ,
many years ago I already used the class Tdatabase, in 1999/2001 I made an application where I found different difficulties,
I used a main window and many child windows in each of which I inserted a dbf with a listbox.
I often encountered the error "alias do not exist" and no one even helped me because at that time there was no fwh forum
but only the newsgroup.

I used this expression


Code: Select all  Expand view  RUN
  USE Customer

   DATABASE oDbf
 


So I had to find another way to use the archives on the local network.

Later I preferred not to deal with this type of connection in order not to run into these errors.


For you first test I wish ask questions:

1) Tdatabase of fwh run ok or have problems ? or I must use anothet tdatabase on commerce..

2) Seeing your source I saw you create at init the index of archives when the app is opened then call

Code: Select all  Expand view  RUN
oCustomers := TCustomers():new()


but Tcustomer class is linked to another class called Txdata

why this ?

why not make a link directly to tdatabase class ?

wich is the problem ?



3) then you call

Code: Select all  Expand view  RUN
oCustomers:last := "Farley 2"   // change
   oCustomers:save()               // save
   msgInfo(oCustomers:last)        // Shows "Farley 2"


I understood you change the name " FArley" into "Farley 2"

because then you call oCustomer:save()

but then when I see the message I see "Farley 2" but then on the browse I see allways "Farley"

and not "Farley 2"


it is not saved ?


on this recent topic
viewtopic.php?f=3&t=36149&p=215576&hilit=tdatabase#p215576


you use directly tdatabase


Code: Select all  Expand view  RUN
oCustomer:= TCustomer():New()


..


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


as you sad on note the index is automatically opened

what is the difference between calling txdata or calling tdatabase directly?
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: dbfs on Network : wich performance method?

Postby James Bott » Tue Oct 30, 2018 3:10 pm

Silvio,

1) Tdatabase of fwh run ok or have problems ? or I must use another tdatabase on commerce..


TDatabase has been working fine all along. Perhaps you were making programming errors.

2) Seeing your source I saw you create at init the index of archives when the app is opened then call

oCustomers := TCustomers():new()

but Tcustomer class is linked to another class called Txdata

why this ? why not make a link directly to tdatabase class ?

I meant to explain this before but I forgot. One of the great things about OOP is that you can move common code up the heirarchy and it is inherited by all the subclasses. If you can write each piece of code only once then you only have to change it once if you need or want to. You also eliminate many lines of code. In this case we only eliminated 2 lines of code in the two individual databases. For example we could have written the customer class like this:

Code: Select all  Expand view  RUN
Class TCustomers from TXData
   Method New()
Endclass

Method New(lShared) CLASS TCustomers
   Default lShared := .t.
   ::super:New("customer", lShared)
   ::use()
Return self
 

But we can move these two lines up the tree for each database:

Code: Select all  Expand view  RUN
  Default lShared := .t.
  ::use()
 

Because they are going to be used by every database class. So, let's say you have 10 databases, this saves you 20 lines of code. Also, having a base class provides you with one place where you can make changes that will be inherited by all the databases. Just for example, let's say you wanted to add a log of all the dates and times every database was opened. You could add this code to the TXData class and all the databases would inherit it, so all would get logged. Or perhaps you want to add deleted record reuse, then you can add that to TXData and all the databases inherit that feature.

I understood you change the name " FArley" into "Farley 2" because then you call oCustomer:save().

But then when I see the message I see "Farley 2" but then on the browse I see allways "Farley" and not "Farley 2"

You missed this code:

Code: Select all  Expand view  RUN
  oCustomers:last := "Farley"
   oCustomers:save()
 

After changing the name to "Farley 2" in the database, I changed it back to the original name so the demo would work every time you run it.

What is the difference between calling txdata or calling tdatabase directly?

I hope I have explained it clearly. I highly recommend that you use a class in between TDatabase and your individual database classes.
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: dbfs on Network : wich performance method?

Postby Silvio.Falconi » Tue Oct 30, 2018 3:37 pm

Good
I must make a mother class txdata and then I can make the other classes for customer, articles, ecc.
in these days I have to try to do something with the teachings you gave me
perhap At first, I can converte a my easy prg with these methods
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: dbfs on Network : wich performance method?

Postby Silvio.Falconi » Tue Oct 30, 2018 3:43 pm

a question
I have a dbf on the root of application I use it for check : on this file I have the folder of archives and the year of operation
sample
year => 2007
DBFPATH = > 2007\data
then there are info data of school . these data are used on reports and other procedures

I must open and manage this file at the same mode ( txdata) or I must open it on esclusive mode ?
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: dbfs on Network : wich performance method?

Postby TimStone » Tue Oct 30, 2018 3:45 pm

Silvio,

I first started programming for networks in the old MS-DOS days, using Clipper. That was over 30 years ago. My clients ( small businesses ) may use anywhere from 2 to 20 computers in each location, and they must all be able to work on the same files, inputting data, all day long. My application has been meeting their needs, quickly and easily, for that whole time.

Many years ago, when moving to FWH, I also adopted tData ( the tdatabase extension ) that James provided. It has never failed me, and made my programming cleaner and easier.

Several years back, I followed James advise on OOPS and moved most of my program into Classes and Methods. I condensed everything to eliminate duplications of processes. It was an excellent move for me, making the code much easier to support, by updates, extensions, and of course debugging.

It is a lot of work. I agree to that. But once it is done, everything else falls into place and thereafter it becomes much easier.

I also use resource files which I know you do not like. However, these allow me to easily create, and enhance, very complex data screens that provide for what my clients want. I recently have attempted to change to a @ x,y format, and so far I find it very difficult to get what I want. I've looked at samples, what little we have for reference material, and asked questions, but so far nothing comes close to giving me the look and feel of my .rc controls, and dialogs. Change is challenging, but in the end, perhaps we do far better for our customers when we take that step. My clients pay me to meet their needs, and so they will always be my top priority.

Finally, for networking, my application will support any number of computers through Microsoft's native networking, but the performance can become very slow and less reliable. So I have put in the capability for them to use the Advantage Database Server, client/server, software. They are then safe and get incredibly fast performance across the network. Some people have experimented with some other Client/Server options but so far no one has posted about success with other systems ( for .dbf ).

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: dbfs on Network : wich performance method?

Postby James Bott » Tue Oct 30, 2018 3:53 pm

Silvio,

I must open and manage this file at the same mode ( txdata) or I must open it on esclusive mode ?

Generally the only reason you need open files in exclusive mode is to pack and/or reindex them.

If every user has to have access to these files, then you need to open them in shared mode.

James
Last edited by James Bott on Tue Oct 30, 2018 4:06 pm, edited 2 times in total.
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: dbfs on Network : wich performance method?

Postby James Bott » Tue Oct 30, 2018 3:56 pm

Tim,

Thanks for your input and the kind words.

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: dbfs on Network : wich performance method?

Postby Silvio.Falconi » Tue Oct 30, 2018 5:04 pm

Dear Tim,

I too started with the Clipper Autumn 86 and then I purchased the Clipper Summer 87 ( I also have the 4 original floppy dishes 5 1/4) of Nuntucket.

On dos it seem too easy I used Netuse made from super lib or Platet lib or another lib I not remember good and it run ok on Network with no problems

When moving to FWHon 1992 (I purchade from a farmer of Bolzano called NOMOS the first fivewin 1.44 Package, this farmer made a clipper Magazzine in Italy )

I had my first problems. Before the forum did not exist and in the newsgroup they hardly answered you.

Generally I always had the errors that I described in the first post and then I gave up and I only looked for small applications without the local network.

I am a self-taught nobody taught me the basics of programming I did classical high school and I started taking the first steps with the zx81, vic20, commodore64
and only in 1987 I used an ibm ps2 / 80 the first year of work when I was 19 years old.


It is not true that I do not like the resource file, for an application that ran on w7 I had problems and after I converted the dialog in source @ x, y the program was faster, obviously I use the resources to insert the bitmaps I prefer to make the dialog dynamic and not resources in order not to burden the exes

James, What does the tdata class consist of?
I think I can not use for now advantage because my budget does not allow me and so I have to make do with what I can have free
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: dbfs on Network : wich performance method?

Postby Silvio.Falconi » Tue Oct 30, 2018 5:18 pm

James,

return on first test sample

the function BuildIndexes() make the indexes

there is an error because I use an old release of customer not have the field ID

but it make the same the index Index on "id" tag "custno" to customer as you can see on this picture

Image

How it can happen ?

Dear Enrico ( Emg) how it can happen ? with your emagdbu read the tag on field but there is not the field ID ?..it's strange

Image
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: dbfs on Network : wich performance method?

Postby Enrico Maria Giordano » Tue Oct 30, 2018 7:00 pm

Probably you are using the new CDX with the old DBF. Try to rebuild the CDX.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: dbfs on Network : wich performance method?

Postby TimStone » Tue Oct 30, 2018 7:04 pm

Silvio,

All of my formal training is in. psychology and education. I was asked to write programs in dBase II starting in 1982. I live close to Ashton Tate, and Nantucket so I was very familiar with their software and all the developers who used to come for conferences. I learned on my own by reading books and attending the conferences.

You can use ADS Local for free. If you build your program with ADS, it can recognize and use the REMOTE option ( the actual client server ) or run using the Microsoft networking ( LOCAL ) for free. One set of code does it automatically for you and is very easy to implement.

Using tdatabase ( or tdata as an extension ) makes programming, and networking, so easy and your code far more readable.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2945
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: dbfs on Network : wich performance method?

Postby Silvio.Falconi » Wed Oct 31, 2018 11:10 am

Enrico Maria Giordano wrote:Probably you are using the new CDX with the old DBF. Try to rebuild the CDX.

EMG


I erased the customer.cdx before and I use the test of James to recreate the index
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: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: dbfs on Network : wich performance method?

Postby Enrico Maria Giordano » Wed Oct 31, 2018 11:24 am

Can you send me the DBF and the CDX to reproduce the problem here, please?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 73 guests