The (1) is easy // This is an example on how to categorize SQL exceptions
// It is only to pass the test
public class MSSQLExceptionConverterExample : ISQLExceptionConverter
{
#region ISQLExceptionConverter Members

public Exception Convert(AdoExceptionContextInfo exInfo)
{
SqlException sqle =
ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as SqlException;
if(sqle != null)
{
if (sqle.Number == 547)
return new ConstraintViolationException(exInfo.Message, sqle.InnerException,
exInfo.Sql, null);
if (sqle.Number == 208)
return new SQLGrammarException(exInfo.Message, sqle.InnerException,
exInfo.Sql);
}
return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException,
exInfo.Message, exInfo.Sql);
}

#endregion
}

2009/8/5 Jason Meckley <[email protected]>

>
> Rather than question the reuse of a corrupted session, I would ask:
> 1. how do you know the exception is a constraint violation?
> 2. why you are expecting a constraint violation?
> 3. why wasn't this accounted for before committing the transaction?
>
> # 3 would solve a majority of your errors? confirm there is not a
> validation constraint before saving.
> There is still the possibility that between validating the constraint
> and committing the transaction the constraint could be broken, but
> this would truly be an exception in which case you want/need to t
> abandon the session and try again. This could be done manually by
> reporting back to the user and allowing them to input new data, or it
> could be handled automatically by the system.
>
> On Aug 5, 5:26 am, YJingLee <[email protected]> wrote:
> > If I save the object, the database violates the constraint, resulting
> > in errors, out abnormal, I would like to once again save the
> > modifications to the object, the Session can not be used, and I do not
> > want to re-opening Session, the continued use of this Session, there
> > is no solution?
> >
>


-- 
Fabio Maulo

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to