Board index » delphi » Ole Automation + "Castastrophic Failure"

Ole Automation + "Castastrophic Failure"

I have created my first ActiveX Automation thingy and I was getting e{*word*277}d
about how neat this stuff is but have ran into a brick wall trying to access
a database from my Automation DLL.

1) I have created an automation (in-process) DLL called ComCtr,  and rego'd
it.

2) I have a simple client that creates an instance of ComCtr, and checks
that it works (the ComCtr DLL displays a log of what it is doing on a debug
form anyway).

So far so good - the ActiveX component works well.

The problem comes when I add a datamodule or simple form to the ComCtr
project and drop on a TTable.

The project still builds OK but the "Castastrophic Failure" message occurs
whenever I try and do _anything_ such as a .Open with a TTable/TQuery or
TDatabase

Note that creating & displaying forms works and doing:
     foo := TTable.Create(nil);
     foo.Free;

seems to work OK.

Anyone ever written an ActiveX Automation Server that access's a database?
Any tips?

___________________________________________
Grant Black
Software Development Manager
Telephony Video Data Ltd

"The stables"
Ponsonby
Auckland
New Zealand

 

Re:Ole Automation + "Castastrophic Failure"


Hi Grant,

I have written an automation server that access SQL Server via ODBC. I
haven't used Delphi's database components for the job though (I use
Guernsey software's ODBC components). Also, my code runs as an
out-of-process server.

I can say that OLE 'catastrophic failures' usually seem to refer to an
invalid pointer operation (like referencing an object that hasn't been
created).

You can step through your automation code in the Delphi IDE to make sure
that things are getting created and accessed in the appropriate order
(or create a log file to track this stuff).

You know that the automation objects use a difference constructor? They
use '.initialize' and they declare it as a procedure not a constructor.
There is some documentation of this in the Delphi on-line help. You
still should call its inherited method though. The destructor is
unchanged.

That could be your problem. Try putting all the .create and .free
statements in one method in your automation server and see if you can do
data access like that.

I hope that helps a little,

Steve Midgley

Quote
Grant Black wrote:
> I have created my first ActiveX Automation thingy and I was getting
> e{*word*277}d
> about how neat this stuff is but have ran into a brick wall trying to
> access
> a database from my Automation DLL.

> 1) I have created an automation (in-process) DLL called ComCtr,  and
> rego'd
> it.

> 2) I have a simple client that creates an instance of ComCtr, and
> checks
> that it works (the ComCtr DLL displays a log of what it is doing on a
> debug
> form anyway).

> So far so good - the ActiveX component works well.

> The problem comes when I add a datamodule or simple form to the ComCtr

> project and drop on a TTable.

> The project still builds OK but the "Castastrophic Failure" message
> occurs
> whenever I try and do _anything_ such as a .Open with a TTable/TQuery
> or
> TDatabase

> Note that creating & displaying forms works and doing:
>      foo := TTable.Create(nil);
>      foo.Free;

> seems to work OK.

> Anyone ever written an ActiveX Automation Server that access's a
> database?
> Any tips?

> ___________________________________________
> Grant Black
> Software Development Manager
> Telephony Video Data Ltd

> "The stables"
> Ponsonby
> Auckland
> New Zealand

Other Threads