Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Update causes Application Exception
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01218577
Message ID:
01219177
Vues:
17
Larry,

>I am using MM .NET Framework 2.4 on a Windows Forms app.
>If an SQL update fails because of a duplicate key (eg. product + class must be unique),
>it causes an Application Exception (instead of just a failed SQL update) and crashes the whole application. I get the following message:
>
>Cannot insert duplicate key row in object 'UserProdXref' with unique index 'userprodtype'.
>The statement has been terminated.
>
>The message is accurate and the user should be able to correct the data so I do I prevent the whole application from terminating?

This should be handled in the business layer via business rules before it ever hits the database. You can add a custom rule to your rule object that makes sure the key is unique.

Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform