Acessing the SQL Error code within a DAL exception


Author
Message
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi,

I want to wrap certain database processing in Try blocks, check any error and retry (within limits) if they are expected, e.g. locking. However, I'm having trouble identifying the native SQL error code within the Exception, e.g.

blTry = True
While blTry
   Try
      Me.FillByStoredProcedure(StoredProc)
      blTry = False
   Catch ex As Exception
      blTry = CheckTheError(ex)
   End Try
End While

I can see the SQL Error Description but I want to evalute errors using native SQL error codes.

Cheers, Peter

Replies
Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Ben,

Perfect - thank you.

Cheers, Peter

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Glad that worked out for you Smile

Oh, and if the type is a DataLayerSavingException, then it will have the exceptions listed within the SavingErrors collection because there might be more than one, but that's only if you set your business object's ErrorSavingMode to ContinueOnError (non default) and wrap the bo.Save() in a try/catch.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search