Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I know how to use try catch blocks to trap any exception and then crank out the ex.Message to a console or windows form.

What I would like to figure out is how to make these exceptions 'smarter'.

 

What I mean is say I am trying to open a connection to an access database. If the db is open already I get an error and I kick back the standard message. What i would like would be to 'know' that which causes the message and return my own message like 'hey just close access up and hit this button to try again'.

 

The trouble I run into when I try to do ANYTHING like this is that I don't know the ex.whatever exception that is being thrown. All I know is what the message in the console is. Then I go through a frustrating round about process to determine how I can trap for it. I have enough experience to know that when you have to do that much work it's because you don't know something and you aren't doing something the right way.

 

What am I missing here?

Wanna-Be C# Superstar
  • Administrators
Posted

The MSDN documentation should help a lot - most function's documentation also lists what exceptions may be raised and under what scenarios, this means at least you can decide what exceptions to trap.

 

Any chance you could post a sample of you existing exception handling code - it may be that you are only missing something simple.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

are you catching the OleDbException (which is thrown by OleDbConnection)?

it has an OleDbErrorCollection with OleDbError objects.

Message

NativeError : Jet's Error message in your case

Source

SQLState

 

In any event, I suspect the error is yours and not the users - check the docs on

Jets NativeError and try and figure out what you're doing wrong

IN PARVUM MULTUM

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...