Trouble with COPY TO command

This forum is meant for questions about the Visual FoxPro Language support in X#.

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

Re: Trouble with COPY TO command

Post by robert »

Guys,
The DBFVFPSQL driver is used internally for the results of SqlExec().

It is the same as the DBFVFP driver, with the following differences:
1) The DBF file is deleted when the file is closed
2) The record length is fixed to 2 bytes (1 byte deleted flag and 1 byte data). There is no need for extra data because the real data is not saved to disk but is stored in memory.
3) It contains a DotNet DataTable. This is the (in memory) location where the data is stored. So, there is no real data in the file, except the deleted flag
4) After creating the file (with DBFVFP) you can open it with DBFVFPSQL and then you are expected to assign a DotNet DataTabe to the DataTable property of the class.
This DataTable must have a structure matching the structure in the DBF header.
Assigning the DataTable takes care of creating a phantom record based on the columns in the table.
5) DbInfo(DBI_ISDBF) returns FALSE. This makes sure that operations such as Copy to Append from do not try to copy the record buffer, but write each field individually

The SqlExec() code first creates a table with the DBFVFP driver, then loads the DataTable from the SQL result set, opens the table with the DBFVFPSQL driver and assigns the DataTable to the DataTable property of the RDD object.

So, to summarize: do not use this for something other than a DBF with a DataTable.


Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 5718
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Re: Trouble with COPY TO command

Post by Chris »

Robert,

Thanks! So in practice, the DBFVFPSQL in 99% of the cases is to be used internally only by SqlExec().

Brian, forgot to mention, in order to fix the COPY TO command issues, you need to apply this cahnge to the file \XSharp\Include\dbcmd.xh :

https://github.com/X-Sharp/XSharpPublic ... 821267eae5
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply