473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Exception Text

Hi, I have a c# program for compacting msaccess databases and I’m now setting
up the exception handling.

For 2 different conditions I get the following messages.

System.Runtime.InteropServices.COMException (0x80040E4D): Not a valid
account name or password.

System.Runtime.InteropServices.COMException (0x80004005): You attempted to
open a database that is already opened exclusively by user 'Test1' on machine
'Dta-TRP'. Try again when the database is available.

I need to show a customized message to show the exception. Is there anyway
to get the above exception text so that I can modify it slightly?

Thanks in advance.

Nov 16 '05 #1
2 3636
check out the System.Exception object

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfSystemExceptionClassTopic.asp

Most exception will be derived from this base class and it providers several
properties - Message, Source, InnerException, StackTrace etc.

The exception type below (System.Runtime.InteropServices.COMException) will
automatically have these properties so you will be able to access the
exception message using the 'Message' property.

HTH
Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.

"jez123456" <je*******@discussions.microsoft.com> wrote in message
news:6A**********************************@microsof t.com...
Hi, I have a c# program for compacting msaccess databases and I'm now setting up the exception handling.

For 2 different conditions I get the following messages.

System.Runtime.InteropServices.COMException (0x80040E4D): Not a valid
account name or password.

System.Runtime.InteropServices.COMException (0x80004005): You attempted to
open a database that is already opened exclusively by user 'Test1' on machine 'Dta-TRP'. Try again when the database is available.

I need to show a customized message to show the exception. Is there anyway
to get the above exception text so that I can modify it slightly?

Thanks in advance.

Nov 16 '05 #2
I've not tested it, but try the following

try
{
// your failing code in here
}
catch (System.Runtime.InteropServices.COMException exception)
{
switch ((uint)exception.ErrorCode)
{
case 0x80040E4D:
// handle error yourself
break;
case 0x80004005:
// handle error yourself
break;
default:
// otherwise rethrow the original exception
throw(exception);
}
}

Regards,
Phil.

"jez123456" wrote:
Hi, I have a c# program for compacting msaccess databases and I’m now setting
up the exception handling.

For 2 different conditions I get the following messages.

System.Runtime.InteropServices.COMException (0x80040E4D): Not a valid
account name or password.

System.Runtime.InteropServices.COMException (0x80004005): You attempted to
open a database that is already opened exclusively by user 'Test1' on machine
'Dta-TRP'. Try again when the database is available.

I need to show a customized message to show the exception. Is there anyway
to get the above exception text so that I can modify it slightly?

Thanks in advance.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: cody | last post by:
public DateTime Value { get { try { return new DateTime(int.Parse(tbYear.Text), int.Parse(tbMonth.Text), int.Parse(tbDay.Text)); } catch (FormatException)
4
by: Bhavya Shah | last post by:
Hello, I am facing a very strange problem in my application. I have a form on which I select a path. I open the FolderBrowserDialog for path selection. Once the path is selected I press a button...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
8
by: Jonah Olsson | last post by:
Hi guys, For my VB.NET application, I created an ErrorHandler class that should save all available information about the last error occurred. I use Server.GetLastError for this. The problem is...
7
by: ZorpiedoMan | last post by:
Well, I'm still wondering around in the "land of the lost exception"... It seems that controls that are bound to a class and the class throws an error in the SET method of the bound member, the...
2
by: Adrian Burka | last post by:
HELP! I have written a web service, and a program in C# using Microsoft Visual C#.NET to interact with the web service. Exception handling isn't working in my application, though. One function...
2
by: Chris Stiefeling | last post by:
Hi, I am experiencing a strange problem. I am reading and writing xml files via XmlDocument and XmlTextWriter. In the debugger everything works fine but outside the debugger (debug or release)...
7
by: puginews | last post by:
I was wondering when you create a new xmltextreader (or any other object for that matter), is it destroyed/closed (memory/resources freed) when an exception occurs ? Dim xmlrdr As New...
0
by: randy.buchholz | last post by:
I am trying to trap the following error. I have tried to catch it on page load and every event on the data source and dd. No luck. I'm forcing the error by setting the dd.text to an invalid value...
4
by: DHS1 | last post by:
Hey guys. I have a lab that is due in two weeks, but I wanted to start on it now. Problem is, I'm at home during christmas break so I can't ask my professors. Here's my problem: I am given a very...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.