Exception handling for database
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Exception handling for databaseExpand / Collapse
Author
Message
Posted 12/09/2005 4:40:54 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 03/25/2006 6:08:39 PM
Posts: 36, Visits: 65
What do you suggest is the appropriate place to trap exceptions that my occur as a result of a database error?
Post #252
Posted 12/10/2005 10:32:59 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 06/17/2008 9:28:35 AM
Posts: 2,649, Visits: 1,863
The best place to catch a database exception is around the Save() call on the business object, or the Save() call on a form.

Basically, you have two options:

1) Set the ErrorSavingMode property on the business object to FailOnError (default) and the business object will bubble up the exceptions from the saving theads. All of the saving threads will abort, causing the rest of the save to fail. (Whether or not the changes on the rows that have already been saved successfully are accepted depends upon the AcceptRowChangesMode.)

2) Set the ErrorSavingMode property on the business object to ContinueOnError and the business object will catch all of the saving exceptions (including the concurrency exceptions). Then it will report the errors to you by doing 3 things:
a) Set the DataRows in error that did not save properly.
b) Collect the save errors and add them to the SaveErrors property on a new DataLayerSavingException.
c) Raise the ErrorSaving event giving you the DataLayerSavingException containing all of the errors (rather than throwing the DataLayerSavingException), including the retrieved server rows for comparision on concurrency exceptions.

So, the FailOnError goes boom if you get an exception while saving, aborts all threads, and throws you the exception. ContinueOnError provides the exception(s) in the ErrorSaving event after the save has completed and all rows that could possibly be saved are saved.



www.bungie.net
Post #253
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 4:20pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.062. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.