In form1.setupForm() I have the following code which should close the application if there are any problems with connecting to the database.
For some reason it just ignores the application.Terminate. Please can someone help.

try
database1.Open;
except
on E:EDBEngineError do
begin
Application.MessageBox('Error connecting','Error',0);
Application.Terminate;
end;

Hi Richard

Maybe there is something preventing it to close, because something else is still opened.

Does it get to the "Application.Terminate" line?
Do you even see the MessageBox?
Use BreakPoints. sometimes it's a great way to know what happens AFTER the exception.

Besides that, i usually use :
If database1.Active Then database1.Close;
database1.Open;
Just to be on the safe side.

I think you can also ignore the "on E:EDBEngineError do".
Because if there is an exception, then why would you need the "on E:EDBEngineError" ?
(but maybe i'm wrong about this one)

hope i helped

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.