How about this as an idea -
ADO uses COM components
The main window loop is not active (exists) until you get Application.run
executed and COM uses this to post messages etc, so maybe COM is attempting
to put a message into the application message loop and dies because it does
not yet exist?
I.e. It may be (probably is) a bad idea to do this in the initialisation.
Would be better to use the singelton type pattern or a function that returns
the object value, but it first checks if the object exists.
Myles.
> -----Original Message-----
> From: Donovan J. Edye [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, 10 February 2000 12:11
> To: Multiple recipients of list delphi
> Subject: [DUG]: What is wrong with this code??
>
> G'Day All,
>
> I am getting a 216 error (In a large app) and a 217 (go figure) in a small
> app that I created (see below for code). The error is occuring when I
> create
> a TADOQuery in the initialization section of a unit. Has anybody got any
> ideas, pointers etc??
>
> Unit1 - Just a blank form, with the only code change being:
>
> implementation
>
> {$R *.DFM}
>
> uses
> Unit2;
>
> and Unit2 is:
>
> unit Unit2;
>
> interface
>
> uses
> ADOdb;
>
> var
> q : TADOQuery;
>
> implementation
>
> uses
> SysUtils;
>
> initialization
> q := TADOQuery.Create(nil);
> finalization
> FreeAndNil(q);
> end.
>
> ------------------------------------------------------------------------
> --Donovan
> Donovan J. Edye [www.edye.wattle.id.au]
> Namadgi Systems, Delphi Developer
> Web: www.namsys.com.au E-Mail: [EMAIL PROTECTED]
> Voice: +61 2 6285-3460 Fax: +61 2 6285-3459
> TVisualBasic = Class(None);
> ------------------------------------------------------------------------
>
> --------------------------------------------------------------------------
> -
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz