xsharp.eu • CopyDB() Method
Page 1 of 1

CopyDB() Method

Posted: Sat Nov 27, 2021 8:50 pm
by Neale
Hello

Since installing XSharp 2.9a Public version the CopyDB() method seems to hang on
large .DBF files ( 75k + records ) and other .DBF’s are copied with few and duplicated
records. Reinstalled 2.8a and all seems OK ?

Neale

CopyDB() Method

Posted: Sat Nov 27, 2021 9:56 pm
by Chris
Hi Neal,

Can you please give us a sample showing the problem? I tried to reproduce it with the code below, but it seems to work fine (output dbf identical to the source dbf), so of course the test is missing something to make the problem manifest itself.

Code: Select all

FUNCTION Start() AS INT
	LOCAL cFileName AS STRING
	cFileName := "c:testcopydb"
	RddSetDefault("DBFCDX")
	DbCreate(cFileName , {{"FLD1","C",20,0}})
	FErase(cFileName + ".cdx")
	DbUseArea(TRUE,,cFileName,,FALSE)
	? "created"
	FOR LOCAL n := 1 AS INT UPTO 500_000
		DbAppend()
		FieldPut(1, StrZero(n,10))
	NEXT
	DbCreateOrder("FLD1",cFileName,"FLD1")
	DbCloseArea()
	? "appended"
	
	LOCAL db AS DbServer
	db := DBServer{cFileName} 
	? db:CopyDB(cFileName + "_copy")
	db:Close()
RETURN 0
[tweet][/tweet]

CopyDB() Method

Posted: Sat Nov 27, 2021 10:33 pm
by Neale
Hello Chris
Your example worked OK.
Will check again and send an example later, a snippet of the code I am using CopyDB ;

oArt3Server := DBServer{ SELF:cArt3Path + "Transact.DBF", FALSE }
oArt3Server:CopyDB( SELF:cArt4Path + "Transact.DBF" )
oArt3Server:Close()
oArt3Server := NULL_OBJECT
SELF:oDCProgressBar1:Advance(1)

Neale

CopyDB() Method

Posted: Mon Nov 29, 2021 9:28 pm
by Neale
Hello Chris
Thanks for your help, I noticed in your example you deleted the associated .CDX file before calling CopyDB(), that solved the problem.
In 2.8a CopyDB() seemed to work without deleting the old .CDX.
All good and thanks again.

Neale

CopyDB() Method

Posted: Tue Nov 30, 2021 12:49 am
by Chris
Hi Neal,

Ah, OK, glad to hear! I had not suspected that this could be the issue, I'm just always doing that before creating a new dbf/cdx set.

.

CopyDB() Method

Posted: Tue Nov 30, 2021 7:24 am
by robert
Neale,

In X# 2.8a we were deleting the production index (the cdx with the same name as the DBF) when creating a new dbf file.
We are no longer doing that because that was not compatible with Visual Objects and several other xbase implementations.


Robert