CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Catch database error

Print topic Send  topic

Author Message
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.
View profile  Send private message
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

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.