Page 1 of 1
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Thu Nov 11, 2021 10:04 pm
by hilberg.it
Hi,
again another issue with my DBF files.
Does anyone have a clue, why this piece of code is only working in VO?
I don't think that is useful code :dry: but it prints out the last 3 records.
In X# on the other hand
_oDbArtikel:Append() returns false
and the
DO WHILE !_oDbArtikel:eof results in an infinity loop with empty entries.
Any ideas why this is happening? It happens only on 2 DBF files. All others work as expected.
Code: Select all
RDDSETDEFAULT("DBFCDX")
...
LOCAL _oDbArtikel as bDBServer
_oDbArtikel = bDBServer{"dArtikel"}
IF _oDbArtikel:Append()
_oDbArtikel:FIELDPUT(#Arname, "Test123")
_oDbArtikel:Skip(0)
ELSE
? "Append returned false"
ENDIF
_oDbArtikel:GoBottom()
_oDbArtikel:Skip(-2)
DO WHILE !_oDbArtikel:eof
? "Arname: "
?? _oDbArtikel:FIELDGET(#Arname)
_oDbArtikel:Skip(1)
ENDDO
_oDbArtikel:Close()
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Thu Nov 11, 2021 11:24 pm
by Chris
Maybe it's a problem with the dbf, maybe a problem with the index, or a problem in the X# RDD, very difficult to say without having the data files.
Some things to try in order to narrow down the problem:
- Can you please try using DBServer instead of dDBServer, does the problem still exist?
- What happens if you reindex the data?
- If this still fails, please zap the data and try again, does it still happen?
Also is it possible to send the data files so that we can have a look?
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Fri Nov 12, 2021 1:17 pm
by ic2
Hello,
What happens if you end your appends with
_oDbArtikel:Commit()
_oDbArtikel:Unlock()
We have seen (in VO) multiple situations where, directly after appending info, especially in loops, one ore more values were empty. Since then we always add these lines ate the end of a loop or single addition.
Dick
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Sat Nov 13, 2021 2:39 pm
by hilberg.it
Thanks to you two.
ic2 wrote:What happens if you end your appends with
_oDbArtikel:Commit()
_oDbArtikel:Unlock()
-> Unfortunately that did not do the trick.
Chris wrote:Also is it possible to send the data files so that we can have a look?
-> I sent you a copy.
I think that the DBF files are quite old and that there might be some corruption. So far I tried to recreate the DBF/FPT Headers using XSharp RDD with this code snippet
Gist
inspired by Roberts idea in this
Thread.
The idea was, using X# RDD to create a new DBF file and paste in the old content. Besides that I used this code snippet to filter for corruptions
Link.
Apparently that solved not all of my problems in the file.
If you see some errors or room for improvement in the
Code please let me know!
Thx
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Sat Nov 13, 2021 6:29 pm
by Chris
Hi Moritz,
Thanks for the files! I think I have good news, I tried your code with this data and it seems to work fine in our current build, see attachment below.
So most likely it's an old bug in the X# runtime which must be fixed now. In a few days there should be a new X# build released, please try again with this one.
- hilberg.png (30.34 KiB) Viewed 739 times
.
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Sat Nov 13, 2021 8:25 pm
by hilberg.it
That is very good news!
Correct me if I am wrong, but shouldn't the output state the appended entry as the last entry? In this case "AuNummer: 123"?!
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Sat Nov 13, 2021 10:46 pm
by hilberg.it
Ok. Just noticed something really strange. If I delete the CDX file, it works and shows the appended entry. Any ideas on this behavior?
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Sat Nov 13, 2021 10:51 pm
by Chris
No, because there's an active index on that field, and the value "123" is not one that would put the record logically last. If I change the value written to the field from "123" to "ZZZ", then indeed the last value shown is this one now.
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Sat Nov 13, 2021 11:02 pm
by hilberg.it
Wow! Thanks. That solves it!
DbServer.Append() is working for some DBF tables only in VO but not in X#
Posted: Sun Nov 14, 2021 9:58 am
by Karl-Heinz
Hi Moritz,
When your append fails it would be interesting to know the content of the error object. What´s e.g. the content of the "Description" property ?
Code: Select all
IF _oDbAuftrag:Append()
_oDbAuftrag:FIELDPUT(#AUNUMMER, "123")
_oDbAuftrag:Skip(0)
ELSE
if _oDBAuftrag:ErrInfo != NULL_OBJECT
? _oDBAuftrag:ErrInfo:Description
else
? "no Error object"
endif
ENDIF
regards
Karl-Heinz