Subject Re: [IBO] How to login to Interbase using TIB_Database
Author Helen Borrie
At 12:57 AM 20-08-02 -0500, you wrote:
>Hmmm...
>
>I've designed a very basic application...one table (CUSTOMER), one form,
>one TIB_Database, one TIB_Query, one TIB_DataSource, one TIB_Grid. I've
>set all my properties to attach to the database (Firebird 1.0.0 on RH
>Linux 7.3) which is at limbo:/var/interbase/test.gdb. I am able to set
>the Connected property on the database and the Active property on the
>query to True, and I'm able to view and scroll the data in design mode
>(I generated 100,000 rows of test data...it's pretty freekin' quick).
>
>Now, I try to actually run the application, and what I get is the form
>with a grid with a single cell in it and NO data. No errors, no
>complaints, just no data. Other than setting the properties in the
>designer, I have not written one line of code (which is sort of futile
>if you don't know WHERE to write it...
>
>What have I done wrong?

You need to start things up in run-time code - this isn't desktop
computing! :-)

Usually at the end of your datamodule's FormCreate event (double click on
the empty OnCreate field in the Events list of Object Inspector to get a
skeleton event handler) :

var
ii: Integer;
begin
inherited;
with MyDatamodule do
begin
if not MyDatabase.Connected then
MyDatabase.Connect;
for ii := 0 to Componentcount - 1 do
begin
if Components[ii] is TIB_Query then
with TIB_Query(Components[ii]) do
begin
<whatever whatever>
if not Prepared then Prepare;
if not Active then Open;
<whatever whatever>
end;
end;
end;

Remember to move the datamodule above the mainform in your DPR as well, so
its objects get created before the mainform starts referring to them...

Helen