Beat-Down Posted December 16, 2003 Posted December 16, 2003 Im getting the error "Cound not save; currently locked by another user." the error is occuring at system.data.oledb.oledbcommand.executecommandtexterrorhandling system.data.oledb.oledbcommand.executecommandtextfor singleresult system.data.oledb.oledbcommand.executecommandtext system.............. can anyone help me trap this error so that I dont try to execute my insert statement when the database is locked? Thanks Quote
Beat-Down Posted December 16, 2003 Author Posted December 16, 2003 I have a Try Catch statement The problem is that if the catch executes the program stops. I want to check and see if its "currently locked by another user" so the error never occures. Quote
kleptos Posted December 16, 2003 Posted December 16, 2003 You can do multiple catch statements for each error and handle the error accordingly. Your application doesnt need to stop if your error handling code can catch the error, show the error, and keep going. try { // You code goes here } catch(OleDbException xec) { // Handle this error here } catch(Exception exc) { // Handle general errors here } finally { // Cleanup goes here } Quote ..::[ kleptos ]::..
Beat-Down Posted December 16, 2003 Author Posted December 16, 2003 So as long as I keep the exception from entering the the general exception the program wont end automatically? Quote
Moderators Robby Posted December 16, 2003 Moderators Posted December 16, 2003 The program won't stop as long as you have any Catch block at all. Quote Visit...Bassic Software
kleptos Posted December 16, 2003 Posted December 16, 2003 If you have the right catch block, your program should never end. Its when the error is not catchable by the catch blocks you have or if you have no catch blocks in your application, then your looking at application failure. If you have a general exception catch block and you still get the .NET Framework error box, it means the error that was thrown is not handled by System.Exception. Just take a look at the error message and usually it will tell you what exception was thrown, then just add a catch block for that exception (put the special catch blocks before the general exception). You should be all set. HTH Quote ..::[ kleptos ]::..
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.