Can't open DBF table

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

dexter
Posts: 11
Joined: Tue Dec 01, 2020 10:14 am

Can't open DBF table

Post by dexter »

I'm trying to open 1GB DBF table with 255 fields on it. X# is complaining and exception is thrown with following message:
"Exception of type 'XSharp.RDD.RddError' was thrown."

The actual description is : "Field 'DAYSCMPL' is not valid"

The field in this table is N(3,2) with index on it. There are no rows with **** on it and the table is opened without issues through VFP.

Any thoughts?
Dimitar
User avatar
Chris
Posts: 4910
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Can't open DBF table

Post by Chris »

Hi Dimitar,

Please create a copy of the file and then delete all its records except just a couple of them. Does the error still happen? If yes, can you please post it here or send it directly to us to have a look? If not, it means there's something specific about the original data, in which case would it be possible to send the complete file? Of course it will be handled with privacy if it contains sensitive data.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
dexter
Posts: 11
Joined: Tue Dec 01, 2020 10:14 am

Can't open DBF table

Post by dexter »

Hey Chris,

I grabbed just first 10 records into a separate table with same struct. Got same error I send this example to you.

Thanks
Dimitar
Attachments
work_temp.zip
(5 KiB) Downloaded 112 times
User avatar
Chris
Posts: 4910
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Can't open DBF table

Post by Chris »

Hi Dimitar,

Thanks, I see where the problem is, it's because this numeric field has a length of 2 for decimals, with a total length of 3, while a total length of at least 4 is expected (decimals + 2).

So I guess VFP allows you to create such fields with no issue? What kind of values can you store in this field, I assume a field value of 1,23 cannot be stored correctly, or can it?
Chris Pyrgas

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

Can't open DBF table

Post by robert »

Chris,

Foxpro allows this and then only stores the decimal point and 2 decimals. So the allowed values are between .01 and .99.

I opened the table and executed:

Code: Select all

REPLACE dayscmpl WITH 999
? dayscmpl
This shows that the value 999 was written.
A value > 999 throws a "Numeric Overflow" exception:

Btw I do not think we should support it in the same way.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
dexter
Posts: 11
Joined: Tue Dec 01, 2020 10:14 am

Can't open DBF table

Post by dexter »

Hi Robert,

Its a tricky on I admit. For VFP decimals are not strict. The fact that you have N(3,2) doesn't mean each number must have 2 decimals. In this case you can safely add 100 or 999 into the field. Of course attempting to put 1000 should end up with exception (in contrast with what VFP is doing).

I'm afraid there might be a lot of cases coming from VFP which does not respect the decimals the way you think they should do.

Kind Regards
Dimitar
User avatar
robert
Posts: 4520
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Can't open DBF table

Post by robert »

Dimitar

It is not the way "we" think, but the way it has been handled by all other Xbase dialects (Xbase++, Clipper, Visual Objects, Advantage, Six driver etc).
FoxPro is the only DBF implementation that allows a value of 999 to be written to a N 3,2 field.
I do not think it was intentional.

Open the DBF in FoxPro and type:

Code: Select all

BROWSE FIELDS dayscmpl
and then try to enter the value 999 in a blank field: it won't work.
I think this is not a feature, but a bug.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
dexter
Posts: 11
Joined: Tue Dec 01, 2020 10:14 am

Can't open DBF table

Post by dexter »

I agree and I disagree.

Here is the DBF specs for Advantage server - https://devzone.advantagedatabase.com/d ... ations.htm

If you look at that file, you will find standard and non-standard implementations as well as VFP-specifics etc. And I know this is probably a huge pain to deal with all but if X# claims it works with one or another dialect, why should VFP dialect suffer from compatibility issues just because the DBF created with VFP are not compatible with DBFs created with Advantage for example (or vice versa)?

If I'm using VFP dialect I don't expect to be able to open DBFs created with Advantage if they contain advantage-specific dbf schema or field types. But I expect the dbf to be fully compatible, non-breakable if being used with X#. Not really expecting you try to fix some "bugs" within the schema.

Speaking about compatibilities - is NULL an option and recognizable? Its probably not for all dialects but if its not standard does it mean X# would throw an exception if trying to open a table with nullable field type? Or how do you cope with the memo field length since memo in VFP is 4 bytes while as it seems the standard is 10?

Dimitar
User avatar
Chris
Posts: 4910
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Can't open DBF table

Post by Chris »

Hi Dimitar,

In the specifications you posted, it is clearly stated that for field type "Numeric", the size of decimals can be "0 to Length-2" :)

So there should not exist a Numeric ("N") field with total length 3 and length for decimals 2.
The other field types that are specific to VFP should be already supported in X#. If there is some that it is not, it's either a bug or work in progress.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
dexter
Posts: 11
Joined: Tue Dec 01, 2020 10:14 am

Can't open DBF table

Post by dexter »

Yes I saw that :)

But here is the case - all VFP community is used with this "bug" as its always being like that in Microsoft's Visual FoxPro. So you can imagine how many "validations" and how many tables exists out there with this bug utilized as a feature. This is quite of a problem if you ask me. Its not only about N(3,2) but also for N(5,2). You are free to enter values like 10000 in such field. For VFP this is legal value and I suppose for X# + VFP dialect it should be the same.

Dimitar.
Post Reply