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