getting complete error information?

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ludek
Posts: 296
Joined: Thu 12 Oct 2006 09:34

getting complete error information?

Post by Ludek » Thu 28 May 2009 10:14

if i execute following query

Code: Select all

begin try
  raiserror('test', 11, 1)
end try  
begin catch
  raiserror('test2', 20, 1) with log
end catch
i get in sql management studio following messages
Msg 2745, Level 16, State 2, Line 5
Process ID 71 has raised user error 50000, severity 20. SQL Server is terminating this process.
Msg 50000, Level 20, State 1, Line 5
test3
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
in sdac, i get just
Der Prozess mit der ID 57 hat den Benutzerfehler 50000, Schweregrad 20, ausgelöst. Dieser Prozess wird von SQL Server beendet.
test3
it means, only 2 of 3 messages that sql management studio gets... how can i get the third?
and, how could i get message numbers, severity levels and lines?

Dimon
Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 28 May 2009 11:14

The third error is generated by SQL Management Studio and therefore you can't get it in application.

Ludek
Posts: 296
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Thu 28 May 2009 14:12

hmmm, it's possible, i don't know...

and exception other info? exception class (=severity), message, procedure and line? i don't know, how could i access these infos with sdac (in vs 2008 are they stored as properties of the exception class SqlException)

Dimon
Devart Team
Posts: 2888
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 29 May 2009 07:11

To get access to the information about all errors generated by SQL server you should catch EMSError exceptions. The EMSError.Errors property contains an array of errors returned by the server and all information about them.
You can find more detailed information about this class in the SDAC help.

Post Reply