Link to home
Start Free TrialLog in
Avatar of shahjagat
shahjagatFlag for United States of America

asked on

Missing Data while reading a .FPT file

Hello,

  I have a .net windows application which imports all the FoxPro data in to sql server database.
For one of the tables in the FoxPro database, I have the .FPT file along with the .DBF file(both files with same name) . I have all the comments fields stored in that .FPT file.
Now, When I try to import, I got all the data from the .DBF file, but I don't see any data coming from the .FPT file.  This FPT file is almost half of the size of .DBF file, around 3.3MB

However, when I tried to import the other table, I got the data from both .DBF file and .FPT file as well. This FPT file size is less than 1MB.
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

The file sizes of FPT files don't relate to the DBF sizes, how large the FPT files are merely depends on how much data is in memo and related field types.

So, do you SELECT * FROM ...DBF and don't get any memo/varchar(MAX)/Text data from that? What driver are you using to read the DBFs?

Bye, Olaf.
Avatar of shahjagat

ASKER

Ok. I am using Oledb driver to read the DBF file and Yes I have a query which select all the fields from that table.
So, how do you judge and detect, you don't get anything from the FPT file? Do you know what to expect from inside? field names and sample content?

There could be much garbage in the fpt, eg values once belonging to records being deleted or emptied, FPT files like DBF files don't shrink before you issue PACK.

You might try to work on a copy of the table(s) and PACK them to see what remains from their FPT file(s).

Assumed cn1 is a oledbconnection, then you can do (VB.net)
Dim cmd As New OleDbCommand( _
"EXECSCRIPT([SELECT 0]+CHR(13)+CHR(10)+[USE thetable.dbf EXCLUSIVE]+CHR(13)+CHR(10)+[PACK])", cn1)
cmd2.ExecuteNonQuery()

Open in new window


Then see how large the packed table and it's fpt is.

Bye, Olaf.
The FPT file can contain a lot of garbage because its space is not reused when you update existing data.

You may query the OLE DB driver version by
SELECT VERSION() AS Ver FROM SomeTable

or by executing the function call:
EVALUATE('VERSION()')
which returns a single string.

How do you recognize FPT data are not at the query output? Whole columns are missing? Or memo columns are empty? Did you try to display DBF+FPT data in Visual FoxPro or in some DBF viewer?

The best way of transferring data from DBF to SQL Server is a very short program written in FoxPro language.
I have data in the FPT file which I can see by opening that file as a word document. I am importing the DBF and FPT files data in to a Datatable. when I check in the Datatable, I see the comments column empty( supposedly it should come  from FPT file). That is the only column in the FPT file.
Word does not recognize garbage in FPT file from real data.
If you rename your file
File.DBF -> File.DBF.TXT
File.FPT -> File.FPT.TXT
then you may post it here (zipped please)
Avatar of jrbbldr
jrbbldr

The contents of the FPT file are the contents of the primary data table record's Memo field(s).  
You cannot get this data separately in any meaningful manner.

I agree with Pavel above in that the best way to get the Memo field data as an integral part of the other field data would be to write a small VFP program to Export the data into a format which could then be input into a SQL Server data table.

Otherwise you could try (no promises here) to get just the left 250 characters from the Memo fields along with the other field data.  

SELECT *, LEFT(MemoFld,250) AS MemFld FROM <VFPTable> WHERE <whatever>

You will get the left 250 characters out of the designated Memo Field into the resultant cursor field named on an associated record-by-record basis.

If the left 250 char adequately covers your needs then good.  
Otherwise find a VFP contractor to help write a small Export program.

Good Luck
Now I see Olaf's comment.

Yes, PACKing the COPY of your DBF+FPT will show the real FPT size.
I got it working. I had a corrupted FPT file . I downloaded it again and it worked.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial