Subject | AW: [IBO] TIB_Query.FieldByName().AsInterger -> Accessviolation |
---|---|
Author | Queck Rainer |
Post date | 2003-05-15T14:12:39Z |
Hello Paul,
thanks for your hints.
Regards
Rainer
-----Ursprüngliche Nachricht-----
Von: Paul Vinkenoog [mailto:paul@...]
Gesendet: Donnerstag, 15. Mai 2003 16:05
An: IBObjects (E-Mail)
Betreff: Re: [IBO] TIB_Query.FieldByName().AsInterger -> Accessviolation
Hi Rainer,
i.e. the query is unprepared. But the Refresh and the First seem to
work, so...
Maybe you could try this - it's better practice anyway:
{ before the loop, but after making sure the query is prepared: }
FieldDest : TIB_Column = MyQuery.FieldByName( 'DESTINATION' );
{ within the loop: }
r := 2 + FieldDest.AsInteger;
This is more efficient because otherwise the field has to be
found-by-name again and again, for every iteration of the loop.
Then step through your code in the debugger and see at what point it
goes wrong.
I know, this is not exactly the answer to you question but it might
help to hunt down the cause.
Greetings,
Paul Vinkenoog
PS:
Hope I got the Pascal syntax OK - it's been a while :-)
Yahoo! Groups Sponsor
<http://rd.yahoo.com/M=253841.3292458.4586253.1261774/D=egroupweb/S=1705007183:HM/A=1504866/R=1/*http://autos.yahoo.com?refsrc=autos/ads/feature/LREC>
2003 Mini Cooper 2003 Nissan 350Z 2003 BMW M3 2003 Honda Accord 2003 Toyota Camry more...
<http://us.adserver.yahoo.com/l?M=253841.3292458.4586253.1261774/D=egroupmail/S=:HM/A=1504866/rand=558536207>
___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .
[Non-text portions of this message have been removed]
thanks for your hints.
>Maybe you could try this - it's better practice anyway:I will follow your procedure, and see what happens:-)
Regards
Rainer
-----Ursprüngliche Nachricht-----
Von: Paul Vinkenoog [mailto:paul@...]
Gesendet: Donnerstag, 15. Mai 2003 16:05
An: IBObjects (E-Mail)
Betreff: Re: [IBO] TIB_Query.FieldByName().AsInterger -> Accessviolation
Hi Rainer,
> I have a Query always doing the same select on the same table.The Access Violation suggests that the fields aren't set up yet,
>
> In a loop :
> <MyQuery>.Refresh;
> with <MyQuery> do
> begin
> First;
> while not EOF do
> begin
> try
> r:=2+FieldByName('DESTINATION').AsInteger;
> except
> ....;
> end;
> ....
>
> I very often end in the exception because of a accessviolation :-(
> What am I doing wrong?
i.e. the query is unprepared. But the Refresh and the First seem to
work, so...
Maybe you could try this - it's better practice anyway:
{ before the loop, but after making sure the query is prepared: }
FieldDest : TIB_Column = MyQuery.FieldByName( 'DESTINATION' );
{ within the loop: }
r := 2 + FieldDest.AsInteger;
This is more efficient because otherwise the field has to be
found-by-name again and again, for every iteration of the loop.
Then step through your code in the debugger and see at what point it
goes wrong.
I know, this is not exactly the answer to you question but it might
help to hunt down the cause.
Greetings,
Paul Vinkenoog
PS:
Hope I got the Pascal syntax OK - it's been a while :-)
Yahoo! Groups Sponsor
<http://rd.yahoo.com/M=253841.3292458.4586253.1261774/D=egroupweb/S=1705007183:HM/A=1504866/R=1/*http://autos.yahoo.com?refsrc=autos/ads/feature/LREC>
2003 Mini Cooper 2003 Nissan 350Z 2003 BMW M3 2003 Honda Accord 2003 Toyota Camry more...
<http://us.adserver.yahoo.com/l?M=253841.3292458.4586253.1261774/D=egroupmail/S=:HM/A=1504866/rand=558536207>
___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .
[Non-text portions of this message have been removed]