sebastianjaurena
Posts: 1
|
| Posted: 05/03/2006, 6:49 AM |
|
Hi, i need catch database error message and change it, but i dont know how to do it.
When i tried to delete (in my application) i get:
DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_Fichas_Bibliograficas_Enfermedades'. The conflict occurred in database 'Inta_AtlasFitopatologico', table 'Fichas_Bibliograficas', column 'ID_Enfermedad'. (Microsoft OLE DB Provider for SQL Server)
And its ok that happend, but i wish that the message be like "Sorry, you must first delete .....".
Thanks.
|
 |
 |
Abs
|
| Posted: 07/18/2006, 8:12 AM |
|
Hi,
I did the following an it works ok for me:
Create a on delete trigger like below on the table that the deletion is going to occur in:
--------------------------------------------------------------------------------------
CREATE TRIGGER DEL_fileType ON [file_type]
FOR DELETE
AS
DECLARE @file_type_id INT
SET @file_type_id = (SELECT file_type_id FROM deleted)
IF EXISTS (SELECT file_type_id FROM file WHERE file_type_id = @file_type_id)
BEGIN
RAISERROR ('<ul><li>Cannot delete as it is being referenced in another table....</ul></li> ',16,1)
ROLLBACK
END
--------------------------------------------------------------------------------------
Notice the HTML I added in the error message <ul><li> this will display the error as bullet point.
hope this helps.
Abs
|
|
|
 |
|