Subject | RE: [IBO] Master/Detail - problems (SOLVED) |
---|---|
Author | Jason Wharton |
Post date | 2004-12-01T02:10:23Z |
Woody, (Can't help but think of Cheers whenever I see your name.)
Actually, I wasn't aware you were using calculated fields. It is most
likely that this is what got screwed up. Show me your OnCalculateFields
event and I can spot the problem.
There are some things in IBO that depart significantly from TDataset that
will bite you if you are not paying close attention to some things.
In short, rather than using FieldByName() you need to use ARow.ByName()
because it is possible that the event could be taking place for the buffer
fields rather than the fields. IBO native buffered datasets have two
cursors and a set of field objects for each one. This set of field objects
is handled by a TIB_Row object. This row object is passed into the event so
that you can operate on the intended row. If it passes in the BufferFields
row instead of the Fields row and you operate using FieldByName() then you
are working with the wrong row object from the wrong row object.
If you want to perk performance by avoiding the ByName() lookup overhead
what you do is maintain a list of integers that carry the field's Index so
you can use indexed referencing for the field objects. Populate these
reference values in the AfterPrepare event of the dataset.
e.g.
In AfterPrepare event:
MyFieldRef := MyQuery.FieldByName( 'MYFIELD' ).Index;
then in your code elsewhere this can apply to both Fields and BufferFields
rows.
ARow.Columns[ MyFieldRef ].AsString ...
HTH,
Jason Wharton
www.ibobjects.com
Actually, I wasn't aware you were using calculated fields. It is most
likely that this is what got screwed up. Show me your OnCalculateFields
event and I can spot the problem.
There are some things in IBO that depart significantly from TDataset that
will bite you if you are not paying close attention to some things.
In short, rather than using FieldByName() you need to use ARow.ByName()
because it is possible that the event could be taking place for the buffer
fields rather than the fields. IBO native buffered datasets have two
cursors and a set of field objects for each one. This set of field objects
is handled by a TIB_Row object. This row object is passed into the event so
that you can operate on the intended row. If it passes in the BufferFields
row instead of the Fields row and you operate using FieldByName() then you
are working with the wrong row object from the wrong row object.
If you want to perk performance by avoiding the ByName() lookup overhead
what you do is maintain a list of integers that carry the field's Index so
you can use indexed referencing for the field objects. Populate these
reference values in the AfterPrepare event of the dataset.
e.g.
In AfterPrepare event:
MyFieldRef := MyQuery.FieldByName( 'MYFIELD' ).Index;
then in your code elsewhere this can apply to both Fields and BufferFields
rows.
ARow.Columns[ MyFieldRef ].AsString ...
HTH,
Jason Wharton
www.ibobjects.com
> -----Original Message-----
> From: Woody (TMW) [mailto:woody-tmw@...]
> Sent: Tuesday, November 30, 2004 2:04 PM
> To: IBObjects@yahoogroups.com
> Subject: Re: [IBO] Master/Detail - problems (SOLVED)
>
>
>
> OK, I solved the problem by using a posted message to perform the
> calculation. That way, the OnCalculateField event can complete it's
> processing before the message is caught and used by the form.
> It seems to
> have solved the problem so I will stick with it.
>
> When I get a little more time, I'll try to look into exactly why the
> calculation screws up the grid control, unless someone else
> already knows.
>
> Thanks,
>
> Woody (TMW)