How to copy fields from a table to DBF! (SDF and Delimited, no problem)

This forum is meant for questions and discussions about the X# language and tools
Post Reply
RolWil
Posts: 99
Joined: Mon Jul 18, 2022 3:16 am

How to copy fields from a table to DBF! (SDF and Delimited, no problem)

Post by RolWil »

Hi all,

My stack: Windows Forms, Harbour. XSharp in VS is current 2.20

This is a carryover.

Assume, you have two databases and a person CAN exist in both. I sync them up on a number, for example their SSN (Social Security Number) . One database could be Active and the other Retirees. I need to find persons who exists in both (or just under 15,000) and print a report.

Proposed solution:
part 1: starting with the original database, create a temporary table, sorted in the correct order and with limited number of people -NO index.

part 2: Close all tables.

part 3: Open the temp table we just created (remember, no index). Then, we open the the second database with its index. Loop: for each person in the temp table we search for them by the SSN and do some stuff if located.

part 4: end of story :)

Question: How to use dbcopy() - or something similar - on a table to create a DBF?

Cheers,
Roland
User avatar
robert
Posts: 4882
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: How to copy fields from a table to DBF! (SDF and Delimited, no problem)

Post by robert »

Roland

Code: Select all

SELECT <tablealias>
COPY TO <newtablename> FOR <forcondition>
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
RolWil
Posts: 99
Joined: Mon Jul 18, 2022 3:16 am

Re: How to copy fields from a table to DBF! (SDF and Delimited, no problem)

Post by RolWil »

robert wrote: Fri Apr 25, 2025 6:59 am Roland

Code: Select all

SELECT <tablealias>
COPY TO <newtablename> FOR <forcondition>
Robert
Thanks Robert, but I get the same generic error I always get: "Value does not fall within the expected range". Where oh where am I going wrong?

Code: Select all

USING System
USING System.Collections.Generic
USING System.ComponentModel
USING System.Data
USING System.Drawing
USING System.Linq

USING System.Text
USING System.Threading.Tasks[attachment=0]Dialect.png[/attachment]

USING System.Windows.Forms

...
...
USE test1/BFMB            
SELECT BFMB
COPY TO test1/BFMBCopy2  FOR TRUE
Attachments
Dialect.png
Referenced.png
RolWil
Posts: 99
Joined: Mon Jul 18, 2022 3:16 am

Re: How to copy fields from a selected DBF to another DBF! (SDF and Delimited, no problem)

Post by RolWil »

Probably should have used : "How to copy fields from a selected DBF to another DBF! "
User avatar
Chris
Posts: 5466
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: How to copy fields from a table to DBF! (SDF and Delimited, no problem)

Post by Chris »

Hi Roland,

Looks like there are some issues with the COPY TO command, we'll look into that. But as you said, you can use DbCopy() instead, for example:

DbCopy("c:\dbf\newdbf", ,{||FIELD->TESTFLD>10})
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
RolWil
Posts: 99
Joined: Mon Jul 18, 2022 3:16 am

Re: How to copy fields from a table to DBF! (SDF and Delimited, no problem)

Post by RolWil »

Chris wrote: Tue Apr 29, 2025 10:45 am Hi Roland,

Looks like there are some issues with the COPY TO command, we'll look into that. But as you said, you can use DbCopy() instead, for example:

DbCopy("c:\dbf\newdbf", ,{||FIELD->TESTFLD>10})
AH! Yes! Thanks Chris. Your suggestion did indeed work.
Post Reply