Subject Re: [IBO] Getting Started Guide.
Author Helen Borrie
At 04:22 PM 10-09-01 +1000, you wrote:

>I do want the datasets to be open when I start the application ... and I tried the following - but it raises exceptions as indicated ....
>procedure TmyDatamodule.myDatamoduleCreate(Sender: TObject);
> ii: integer;
> with myDatamodule do
> begin
> if not Connection.connected then
> Connection.Connect;

> // connect ib_queries I don't understand.

What don't you understand?

> for ii := 0 to ComponentCount - 1 do
> begin
> if Components[ii] is TIB_BDataset then <-- try changing to tib_Query
> with Components[ii] as TIB_BDataset do <-- try changing to tib_Query
> Components[ii].Open // Undeclared identifier "Open"
> else if Components[ii] is TIB_Cursor do <-- change 'do' to 'then' (bad pasting!)

(* you might need this too *)
with Components[ii] as TIB_Cursor do
> Components[ii].First;
> end;
> ...
> end;

The point of the difference is that you call Open to open a bi-directional dataset, whereas you call First on a unidirectional one to open it.

If you don't have any tib_cursors that you want to open, don't include the ELSE clause - it's just unnecessary code clutter.

An alternative syntax for casting the component would be


If you have already established the class of the object with 'IS', Delphi is supposed to allow you to call the methods of the class without explicitly casting it with 'AS'. For some reason, it doesn't always allow it, which is why I gave you the more verbose syntax - that should always work.

Also, you mentioned previously that you had dropped an ib_transaction (named Transaction) into your datamodule. Are you using that transaction? If so, make it the default transaction of your connection object and, for now, link your datasets to it via their ib_transaction property.


All for Open and Open for All
InterBase Developer Initiative ยท