Exceptions not treated properly with SQL Server Express 2005 database



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
.



Relevant Pages

  • Re: ASP.NET 2.0 - a newbie question
    ... the exception can be identified using the exception stack trace below. ... established connection failed because connected host has failed to ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& ... Microsoft SQL Server? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Driver corrupts prepared statements in pool.
    ... This test case demonstrates a bug in the Microsoft SQL Server 2005 JDBC ... cause an exception the next time it is used. ... Microsoft SQL Server 2005 JDBC driver 1.0.809.102 ... // A connection will NOT work properly until it has been ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: IIS ASP.net Web Services Disconnected
    ... does show no exception, and it is a perfect run on the server-side. ... the connection idle for more than 1/2 hours, ... the server thinks the file is send without problem. ... At the client-side, it times out after 1.5 hours if nothing happen. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: System.Security.SecurityException {Beginner working with ASP.NET}
    ... seems like the server is runnning with partial trust. ... In the page_load I fill the data adapter, ... grid and close the connection. ... I get this exception when attempting to view my webform in IE6. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: How to reconnect to a db automatically?
    ... Dim MyConn as new Odbc.connection ... 'The connection could not be opened ... Catch ex as exception ... For instance if the sql server is just rebooting after an update, ...
    (microsoft.public.dotnet.languages.vb)