Re: Exceptions not treated properly with SQL Server Express 2005 database



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
--

.



Relevant Pages

  • MergePullSubscription() - specified module could not be found?
    ... with an SQL Server 2005 database. ... The install was created using ... The exception is ...
    (microsoft.public.sqlserver.replication)
  • RE: Backup & Monitoring not working!
    ... Error message in Windows Small Business Server 2003: ... Microsoft CSS Online Newsgroup Support ... This newsgroup only focuses on SBS technical issues. ... An unhandled exception occurred during the execution of the ...
    (microsoft.public.windows.server.sbs)
  • Native Exception During Merge Replication
    ... We are experiencing a native exception during merge replication between SQL ... Server CE 2.0 and SQL Server 2000 SP3. ... Synchronize method of the SqlCeReplication object. ...
    (microsoft.public.sqlserver.replication)
  • Native Exception During Merge Replication
    ... We are experiencing a native exception during merge replication between SQL ... Server CE 2.0 and SQL Server 2000 SP3. ... Synchronize method of the SqlCeReplication object. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Sharepoint 2007 - Installation Error - Failed to register SP s
    ... Windows 2000 Server. ... It is a bug with Beta 2 where the database server is running Windows 2000. ... Server I have the following exception: ... RunBehavior runBehavior, String resetOptionsString) ...
    (microsoft.public.sharepoint.portalserver)