On Wed, 07 Feb 2007 00:57:00 +0200, ap <ap@[EMAIL PROTECTED]
> waffled
on about something:
>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?
Yes, sorry, it's just my own logging routine. Just does a few things
like check compiler param for debug being set and creates/appends to a
log file of todays date.
In this instance it might as well be showmessage.
>> 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?
Sorry, yes the ID is an autoinc field in database. I didn't bother
with any of the adoquery2 code as I have already narrowed the error
down to retrieving the ID from the insert.
>> 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?
Nope, no afterpost.
>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]);
I'll give that a try, but I wasn't sure if the ID field would have
been generated at that point before the post.
>> 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.
Even worse than that, this is somebody else's code!
Originally it was mine, then someone else vandalised it (it's the only
word for it) then they left and I get it back.
>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
No, I think you've got the right idea re the problem. Sorry for
causing confusion with my log routine.
Thanks for the suggestions, I'll put some more logging in and see if
the ID field is more reliable before the post.
Cheers
Dodgy.
--
MUSHROOMS ARE THE OPIATE OF THE MOOSES


|