DBF changes not visible to second program.

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Jamal
Posts: 315
Joined: Mon Jul 03, 2017 7:02 pm

DBF changes not visible to second program.

Post by Jamal »

Two programs open the same DBF via DBFCDX driver in shared mode.
If the first VO program adds/updates a DBF record (rlock, commit, unlock), the first app see the changes, but the second X# (or C#) program does not see the changes and oDBServer:Seek(..) fails . If the second program closes the DBF and opens it again, the changes are visible.

BTW, i tried DBServer and direct VODB functions with the same result.

I wrote the above earlier, and now while "playing around", I added oDBServer:OrderKeyCount() just before the oDBServer:Seek(...) and the changes are visible and Seek() works!! I tried Skip(0), GoTop() methods but those had no effect.

What's going in OrderKeyCount() which resolves the issue?

Jamal

The OrderKeyCount() from DBServer2.prg is below:

Code: Select all

METHOD OrderKeyCount( uOrder, oFSIndex ) 
	//SE-060601
   LOCAL dwCurrentWorkArea AS DWORD
	LOCAL uRetVal AS USUAL
	LOCAL oError AS USUAL
	LOCAL cTarget AS STRING

	#IFDEF __DEBUG__
		DBFDebug("Entering "+__ENTITY__, AsString(uOrder), AsString(OFsIndex))
	#ENDIF

	lErrorFlag := FALSE
	BEGIN SEQUENCE
		VODBSelect( wWorkArea, @dwCurrentWorkArea )
		IF IsObject(oFSIndex) .and. __Usual.ToObject(oFSIndex) IS FileSpec VAR oFS
			cTarget := oFS:FullPath
		ELSE
			IF IsString( oFSIndex )
				cTarget := oFSIndex
			ENDIF
		ENDIF
		IF ! VODBOrderInfo( DBOI_KEYCOUNT, cTarget, uOrder, @uRetVal )
			BREAK ErrorBuild(_VODBErrInfoPtr())
		ENDIF
		__DBSSetSelect( dwCurrentWorkArea )

	RECOVER USING oError
		oErrorInfo := oError
		__DBSSetSelect( dwCurrentWorkArea )
		SELF:Error( oErrorInfo, #OrderKeyCount )
		uRetVal := NIL
	END SEQUENCE


	#IFDEF __DEBUG__
		DBFDebug("Leaving "+__ENTITY__, AsString(uRetVal))
	#ENDIF
	RETURN uRetVal
User avatar
Chris
Posts: 4599
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

DBF changes not visible to second program.

Post by Chris »

Thanks Jamal, this is a known (after the previous release) problem, Robert is working on a fix for it now. About OrdKeyCount(), I guess it just forces a reread from file, so the problem does not happen.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Jamal
Posts: 315
Joined: Mon Jul 03, 2017 7:02 pm

DBF changes not visible to second program.

Post by Jamal »

Thanks Chris for the confirmation! Will wait for next update.

Jamal
Post Reply