Re: Exceptions not treated properly with SQL Server Express 2005 database
- From: "Graham Harris" <ng@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 20 May 2006 10:59:15 -0700
Radu Stanciu wrote:
Hi,
I'm using an ADOConnection object to connect to a SQL Server 2005
server and I want to catch the exception that occurs in case the
application is trying to connect and the server is not running (or
not installed).
The code I have is pretty simple:
try
// initializing main database connection
DataModuleMain.SQLServerConnection.Open;
except
on E: EOleException do MessageBox(Handle, PChar(E.Message),
'ERROR', mb_OK); end;
The problem is that even the connection fails, the application
doesn't go into the except clause, but rather throws a delphi
exception saying "raised exception class EOleException with message
'SQL Network Interfaces: Error Locating Server/Instance Specified
[xFFFFFFFF]'". Is there a way I can catch and treat this exception
myself? Are there any connection properties that I'm missing?
I've also tested on an invalid query and the behavior is similar, the
exception does not get handled.
Thanks for your help.
Radu Stanciu
Try changing
except
on E: EOleException do MessageBox(Handle, PChar(E.Message),
'ERROR', mb_OK);
end;
to
except
on E: Exception do MessageBox(Handle, PChar(E.Message), 'ERROR',
mb_OK);
end;
HTH
Graham Harris
--
.
- References:
- Exceptions not treated properly with SQL Server Express 2005 database
- From: Radu Stanciu
- Exceptions not treated properly with SQL Server Express 2005 database
- Prev by Date: Re: MS SQL -> ACcess Data Export (Nearly 2 000 000)
- Next by Date: Re: MS SQL -> ACcess Data Export (Nearly 2 000 000)
- Previous by thread: Exceptions not treated properly with SQL Server Express 2005 database
- Next by thread: File system indexing - SQL
- Index(es):
Relevant Pages
|