TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Darren Murray
NA
11
23.3k
OleDb Exception Handling
Jul 22 2011 11:41 PM
Hello. I am new to C# and have a question regarding catching specific exceptions. Below is my code and I would like to know if there is a better way. I would like the catch the specific OldeDbException for "invalid passsword" but how can I do this? What would I place in the Catch() statement? I used an if/then statement to catch it but is there another way in the catch block to specify an exact exception (invalid password)?
tx
try
{ dbConn.Open();}
catch (OleDbException e)
{
if (e.ErrorCode == -2147217843)
{Console.WriteLine("Invalid Password Entered"); }
else
{ Console.WriteLine(e.Message);}
}
Reply
Answers (
3
)
GamingCafe App (ctrl+alt+delete)
Creating a user control