CopyDB() Method

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
Neale
Posts: 24
Joined: Sat Mar 25, 2017 10:40 pm
Location: United Kingdom

CopyDB() Method

Post 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
User avatar
Chris
Posts: 4870
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

CopyDB() Method

Post 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]
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
Neale
Posts: 24
Joined: Sat Mar 25, 2017 10:40 pm
Location: United Kingdom

CopyDB() Method

Post 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
User avatar
Neale
Posts: 24
Joined: Sat Mar 25, 2017 10:40 pm
Location: United Kingdom

CopyDB() Method

Post 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
User avatar
Chris
Posts: 4870
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

CopyDB() Method

Post 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.

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
robert
Posts: 4497
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

CopyDB() Method

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply