Dodgy wrote:
>
> adoquery1.FieldByName('PA_id').asstring:=''; // TBA, maybe
> adoquery1.Post;
> Log('Link ID '+adoquery1.FieldByName('id').AsString]);
It's not easy to understand code written by someone else, and without
any comments. It took me a while to find that the Log-line is for your
own personal debugging aid only, or is it?
> The problem is every now and then the id field comes back with
Where exactly is the ID strange, in your adoquery1 or adoquery2 table?
You also gave no hint where does this first adoquery1 get it's 'id'
content, AutoInc Field probably? Nor any hint how you pass the same ID
to the second adoquery2. The Log-routine you introduced probably is not
your means to do that, or is it?
> If I look at
> 222021 (which I don't have in my log), sure enough I find the record I
> inserted, which was re****ted as being 9719.
Then, that clearly tells that in those cases something is happening
between these two lines:
adoquery1.Post;
Log('Link ID '+adoquery1.FieldByName('id').AsString]);
The cursor in ADOQuery has moved elsewhere, to some older record. This
time it happens to be 9719, and your logging routine writes it down.
Could you have forgotten some sly code in your ADOQuery1.AfterPost
event?
Or if there was nothing, then you could try haunting that something by
adding one more line to Logging code:
Log('Link ID Before Post '+adoquery1.FieldByName('id').AsString]);
adoquery1.Post;
Log('Link ID '+adoquery1.FieldByName('id').AsString]);
> Any ideas? It's really doing my head in.
I know the feeling:) And once you find the reason, you can't believe it
took you two whole days to catch this kind of silly typo in your own
code.
Sorry if I undestood the whole question and problem wrong, I do not use
TADO myself. Yet many of these DB and SQL problems are quite universal.
-ap


|