Capturing error message with raiserror in stored procedure

Topics: Data Access Application Block
Apr 15, 2009 at 3:42 PM
 Hi, I would like to know how canI capture the error message from SQLserver with enterprise lib?

 Database db = DatabaseFactory.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand("deletesomething");
db.AddInParameter(cmd, "@id",, id);       
 Create proc deletesomething  ( @id int )         
            IF exists (select 1 from childtable where id=@id)
                   Raiserror('Error Message')
            Delete mytable where @id=id
Apr 15, 2009 at 4:40 PM
Edited Apr 15, 2009 at 4:43 PM
Catch the SqlException and check it Message property.

catch (SqlException exc){

i'm not sure that the data data access app block behaves like this. but give it a try...if not check the message type that 
its been thrown.