I did similar tests long time back on configurations with Network Server and several clients,
Today I do not have access to such networks. I tested on my home network with two PCs connected over WIFI to my router.
I have used our familiar dbf "customer.dbf".
I request other users having access to small of large networks to do this test and post the results for the benefit of all other users.
First make sure the Server (or one of the PCs) has customer.dbf.
Because we want to test the flushing of index butters also, let us create and use customer.cdx.
First run this program to make sure we are using a proper cdx file.
prepare.prg
- Code: Select all Expand view
#include "fivewin.ch"
REQUEST DBFCDX
function Main()
local cPath := "" // network path
? "Re-creating index"
FERASE( cPath + "CUSTOMER.CDX" )
USE ( cPath + "CUSTOMER" ) EXCLUSIVE VIA "DBFCDX"
FW_CdxCreate()
CLOSE DATA
? "Finish"
return nil
Please assign your network path of the folder containing the customer.dbf to the "local cPath :="
Then build and run the program.
Now I am giving (1) writer.prg and (2) listner.prg
writer.prg:
- Code: Select all Expand view
#include "fivewin.ch"
#include "dbinfo.ch"
#include "set.ch"
REQUEST DBFCDX
function Main()
field CITY
local oDlg, oFont, oGet
local cPath := "" // set your network path
local cSave
USE ( cPath + "CUSTOMER" ) NEW SHARED VIA "DBFCDX"
GOTO 100
cSave := CITY
//
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
DEFINE DIALOG oDlg SIZE 400,180 PIXEL TRUEPIXEL FONT oFont ;
TITLE "CUSTOMER(100)"
RELEASE FONT oFont
@ 40, 20 SAY "CITY : " GET oGet VAR FIELD->CITY SIZE 300,30 PIXEL OF oDlg ;
WHEN ( DBRLOCK() ) VALID ( oDlg:Update(), .t. ) UPDATE
@ 80, 20 SAY "OrdKeyNo : " + cValToChar( OrdKeyNo( "CITY" ) ) ;
SIZE 200,30 PIXEL OF oDlg UPDATE
@ 140, 20 BUTTON "Unlock" SIZE 140,30 PIXEL OF oDlg ;
ACTION ( DBRUNLOCK(), oDlg:Update(), oGet:SetFocus() )
@ 140,280 BUTTON "Close" SIZE 100,30 PIXEL OF oDlg ;
ACTION ( DBRUNLOCK(), oDlg:End() )
ACTIVATE DIALOG oDlg CENTERED ;
VALID (DBRLOCK(), CITY := cSave, DBRUNLOCK(), .t. )
return nil
Again assign to "local cPath" your network path the folder containing customer.dbf
Please note that we are using DBRUNLOCK() only to save the changes and not using COMMIT anywhere
listner.prg
- Code: Select all Expand view
#include "fivewin.ch"
REQUEST DBFCDX
function Main()
field CITY
local oDlg, oFont, oSay, oTimer
local cPath := "" // set your network path
local cSave
USE ( cPath + "CUSTOMER" ) NEW SHARED VIA "DBFCDX"
GOTO 100
cSave := CITY
//
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
DEFINE DIALOG oDlg SIZE 300,180 PIXEL TRUEPIXEL FONT oFont ;
TITLE "CUSTOMER(100)"
RELEASE FONT oFont
@ 40, 20 SAY "City : " + CITY + CRLF + ;
"OrdKeyNo : " + cValToChar( OrdKeyNo( "CITY" ) ) + ;
+ CRLF + "Time : " + TIME() ;
SIZE 260,80 PIXEL OF oDlg UPDATE
@ 140, 20 BUTTON "Close" SIZE 80,30 PIXEL OF oDlg ;
ACTION oDlg:End()
oDlg:bInit := <||
DEFINE TIMER oTimer OF oDlg INTERVAL 10 ;
ACTION ( DBSKIP( 0 ), If( CITY == cSave,, ( cSave := CITY, oDlg:Update() ) ) )
ACTIVATE TIMER oTimer
return nil
>
ACTIVATE DIALOG oDlg CENTERED ;
VALID ( oTimer:End(), .t. )
return nil
This program displays the values and keeps checking for changes in the data with a timer. The moment, changes are detected, the values are updated and displays with time.
Please also note that the OrdKeyNo() also is displayed. Changes in this value indicate that all index buffers are also flushed and visible to the other users on the network.
1) Build and run the "writer.prg" on one of the client PC or Server.
2) Build and run the "listner.prg" on all other clients in the network.
The moment you change the value and "press Unlock button", you will see the changes on all other clients on the network.
This is enough proof that COMMIT is not necessary.
Next:
Add this line
- Code: Select all Expand view
SET HARDCOMMIT OFF
to the Writer.prg and rebuild and run.
You will notice the behavior to be the same.
So,
COMMIT of NO COMMIT
SET HARDCOMMIT ON or OFF
Modify and UNLOCK is all that is enough.