|
-
Oct 13th, 2011, 03:24 PM
#1
Thread Starter
Member
VB6 DAO Error Handling
Hello, all. I've been maintaining a legacy system for a while now that uses VB6 with an MS Access database on the back end using DAO for communication. I'm still working on getting something developed under .NET with a "real" RDBMS, but in the meantime I'm doing everything I can to keep the existing system afloat.
One of the biggest problems I've found so far is the number of DAO errors that come up when multiple users are in the database (shocking, huh?). Most of these are related to table/record locking, so I figured I might try to find a way to better handle those types of errors.
I've now come up with the use of a function to determine whether or not the error is "serious" enough to stop execution of the application. After researching online, I've gone through the entire list of trappable MS Jet and DAO errors. I think I have a list of "acceptable" errors for which I can simply put in a little sleep timer and let the application try the operation again (not indefinitely, of course). What I need now is bascially some confirmation that these errors are indeed "acceptable". Here's my preliminary list:
ERROR MESSAGE
3009 You tried to lock table <table> while opening it, but the table cannot be locked because it is currently in use. Wait a moment and then try the operation again.
3158 Could not save record; currently locked by another user.
3186 Could not save; currently lockec by user <name> on machine <name>.
3187 Could not read; currently lockec by user <name> on machine <name>.
3188 Could not update; currently locked by another session on this machine.
3197 The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.
3211 The database engine could not lock table <name> because it is already in use by another person or process.
3212 Could not lock table <name>; currently in use by user <name> on machine <name>.
3218 Could not update; currently locked.
3254 ODBC - Cannot lock all records.
3260 Could not update; currently locked by user <name> on machine <name>.
3261 Table <name> is exclusively locked by user <name> on machine <name>.
3262 Could not lock table.
3330 Record in table <name> is locked by another user.
3412 Cannot perform cascading update on the table because it is currently in use by another user.
3413 Cannot perform cascading operation on table <name> because it is currently in use by user <name> on machine <name>.
3414 Cannot perform cascading operation on table <name> because it is currently in use.
3418 Cannot open <tablename>. Another user has the table open using a different network control file or locking style.
3624 Could not read the record; currently locked by another user.
3667 A different operation is preventing this operation from being executed.
I've found confirmation on some of these, but I would like to be sure I don't add more than I need and end up missing an error that may indicate a serious problem with the database, rather than just a table/record lock that hasn't been lifted yet.
BTW, here's the code for the DAO error trapping I'm thinking of using. Let me know what you think, and thanks so much for your input and help.
VB Code:
Public Function DAOErrorRetry(ByRef ErrorCount As Integer) As Boolean
If ErrorCount <= 5 Then
If Err.Number = 3008 Or Err.Number = 3009 Or Err.Number = 3158 Or Err.Number = 3186 _
Or Err.Number = 3187 Or Err.Number = 3188 Or Err.Number = 3197 _
Or Err.Number = 3260 Or Err.Number = 3261 Or Err.Number = 3262 _
Or Err.Number = 3211 Or Err.Number = 3212 Or Err.Number = 3218 _
Or Err.Number = 3254 Or Err.Number = 3330 Or Err.Number = 3412 _
Or Err.Number = 3413 Or Err.Number = 3414 Or Err.Number = 3418 _
Or Err.Number = 3624 Or Err.Number = 3667 Then
Sleep 500
ErrorCount = ErrorCount + 1
Err.Clear
DAOErrorHandler = True
Else
DAOErrorHandler = False
End If
Else
DAOErrorHandler = False
End If
End Function
Last edited by G_Hosa_Phat; Oct 13th, 2011 at 03:33 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|