Invalid Field Length in dBase III file?

Hello,

I am parsing what I believe is a "dBASE III, index present" file using Java.  At least that is what DBF Viewer tells me it is.

As I read in the field descriptors, the first 15 or so read in normally, parsing the field name, type, and length.  But suddenly when I come to a field of type character named "Notes" that DBF Viewer is telling me should be length 250, I am reading length "-6" .

Does anyone have an idea what this might be?  As I said, all the other fields to that point seem to be normal.

Thanks in advance!

John
2djohnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

2djohnAuthor Commented:
BTW, if this question belongs in a more appropriate area of the Database forums, please let me know.  I haven't used this area of EE much.  Thanks.
0
CarlWarnerCommented:
The maximum number of characters per field is 254.  So, those numbers surely aren't corresponding with this limit.

Since it says "Notes", I'm guessing that field may be a memo field which has yet another file where the actual "Notes" data resides.  If it is true dBASE, a file name with the extension .dbt should be hanging around.  If it's really FoxPro data, a similar file name with the .fpt extension should be hanging around.  If a memo file is missing and a .dbf is referencing it, you could easily get odd results.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
2djohnAuthor Commented:
Hi Carl,

Thanks for your comment.  2 things though:

1) as I mentioned, the field length is 250, under the 254 limit
2) there is a .fpt file in the same dir

The data is showing up correctly in the DBF Viewer software, notes and all.  The data type byte is saying it's char data- would it be very different if it was a memo?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

CarlWarnerCommented:
Well, now we know it's actually FoxPro data and not pure dBASE.  While they used to be very compatible in the old days, they are not very compatible any more.

If "Notes" shows as Char data, that's fine.  But, if you have an .fpt file, that says there must be a memo field referenced somewhere in the .dbf file.  If you see another field that returns a Memo type, then "Notes" may not be of Memo type.  I sure can't tell from here what it really is.  But, as I initially posted, memo fields can give odd results in these so-called viewers.  The environment in which they were created probably reads that data without issue, as well as showing the true data types.  A memo field can hold any kind of data, ASCII or binary, and is not limited to just character data, but can be just character data if that was the intent of what the system was supposed to hold.

Here is a reference that lays out the bytes of the header (ignore the article title):

ERR: "Not a Database File"; How to Modify Database Header
http://support.microsoft.com/default.aspx?scid=kb;en-us;98743
0
2djohnAuthor Commented:
Carl,

The strange thing is that it is the field descriptor that is giving the strange results?  I could see if the data was bogus, but strange that the descriptor would have a negative number.

Thanks,

John
0
CarlWarnerCommented:
If the data were a memo field, you wouldn't see the data if the field descriptor didn't somehow know it was a memo field and then extract the data out of the appropriate location in the .fpt file.  So, if you actually see data in the .dbf, the field type shouldn't be of the memo type.  But, I don't know how that viewer you have displays memo data.  Again, if you have an .fpt file, there should be one field in that table/.dbf that actually is a Memo field and that is what the viewer should return if the viewer is working properly.

But, I can't figure that out from here. <s>
0
JesterTooCommented:
If the fpt file goes with this dbf they will both have the same base filename... i.e.  abc.dbf and abc.fpt

This may be a problem with the JDBC driver not supporting xbase memo files... there have been several "flavors" of them over the past 20 years and they weren't very compatible with each other.  Which JDBC driver are you using?  Also, what "dbf viewer" are you using?  (Extended Systems has/had one available for free that worked with their Advantage Database Server product that, I believe, can work with stand-alone files when used in "local server" mode... I'm failry sure this version handles Clipper/Foxpro(2.6) style FPT files).

The field designator for a memo field in all the xbase flavors I've used has been "M".  The memo field in each row of the dbf stores a short binary value that is the offset into the fpt file where the text of the memo begins... any given memo not all be contiguous so there can be another pointer in this data that points to the next chunk... and so on and so forth.  Some versions of memo files also stored "back pointers" so all the blocks were chained backwards and forwards.  This gave a bit more stability to these versions of memo files.  Many developers avoided using memo files... they were notorious for becoming corrupted and losing all the content.  The double pointers made them slightly less prone to breaking.

HTH,
Lynn
0
JesterTooCommented:
There are free utilities available that can examine your dbf's and report the data structure if you need...

Go to this site:  http://www.the-oasis.net/

and navigate the following links...
   Source Code Archive
   The Reef FTP Site
   Clipper Code

and scroll down the list of files.  Look for data_doc.zip (158kb) and dbinfo.zip (12kb).  I've used these years ago until I wrote my own version with a few more features... but they should be adequate to interrogate your dbf(s).  Since this is downloaded code, I'd run these programs against copies of the dbf(s) just to be safe(er).
0
2djohnAuthor Commented:
Thanks for all of your input everyone.  Here is more information:

1) I have to read the dbf data after uploading it from a web page, so there is no JDBC involved- I am reading in a byte array.  My code works on other .dbf files, just not this one

2) I have downloaded a few different DBF viewers, and they all show the field in questions as type "C", size 250, Precision "0", and offset "402".

3) To confirm that this is not a memo field, I tried deleting the associated .fpt file, and I was still able to view the file in the different viewers.  So maybe there was a memo field with this database once, but not now?

Thanks,

John
0
2djohnAuthor Commented:
By the way I would be happy to e-mail anyone the files in question if any experts think it would help.

I guess the main thing that confuses me is how all the different DBF viewers are able to read the field and database correctly, but for some reason my parsing code is picking that one field up as size -6...
0
2djohnAuthor Commented:
Experts- I have solved the problem- it was as simple as reading in an unsigned byte rather than a signed one.  I apologise for taking your time, and appreciate your feedback.  I will split the points up.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.