Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Update causes Application Exception
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01218577
Message ID:
01219177
Views:
18
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform