473,558 Members | 2,876 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving teh source of an error

Hello,

When you get an error in a VB.NET program, is it possible to know what is
the origin of the error. I assume it can be VB.NET, the framework, a
database engine, the database itself (Access, SQL Server, ...).

How can you know which source has thrown the exception?
Some error messages are in English, some in my own language.

Many thanks and greetings,

Michel
Aug 10 '07 #1
2 1118
On Aug 10, 12:16 pm, "Michel Vanderbeke" <michel.vanderb ...@skynet.be>
wrote:
Hello,

When you get an error in a VB.NET program, is it possible to know what is
the origin of the error. I assume it can be VB.NET, the framework, a
database engine, the database itself (Access, SQL Server, ...).

How can you know which source has thrown the exception?
Some error messages are in English, some in my own language.

Many thanks and greetings,

Michel
Try
'// Bad code here
Catch (ex as Exception)
'// Examine the variable 'ex' here to determine the problem from
'// useful properties such as StackTrace and Message etc.
End Try

Thanks,

Seth Rowe

Aug 10 '07 #2
If you are using sql server to connect to databases, you can obtain error
messages generated by sql server in the language your user is using.
Import System.threadin g.thread

In the connection string add Language=MyUser Language wher you previously
deteremined the language the user is using as follows

MyUserLanguage = CurrentThread.c urrentUIculture .Tostring
Set the connection string before you fill the dataset.

In the try catch block you can use
catch ex as .......
Where you can look at the list of possible values, for instance you will see
that you can catch an odbc exception
you can have several catch statements in the same try catch block each one
directed to find a different type of exception.
Try
catch exo as Oledb.oledbexce ption
you get oledb error info if an oledb error occurs
CatchExs as exception
you get standard exception info
end try
Some exceptions will not return localized text, others like sql server will
if you specify the Language being used.
I would create Resource files for the errors I expect, one for each language
being used and make error messages in each language so then you can use
My.resources.th enameof the Errormessagekey and the program will pick up your
localized error messages. The standard ex.message and ex.stack trace will be
in English and should not realy be shown to the user.

You can create an exception class that shows a form with texboxes for info
on Whathappened, How it affects the User, what the user can do and
additional tech info. and if you feel it necessary you can take screen shots
and mail untrapped errors to tech support.

In Vs2005 you can use the application event on untrapped error to trap these
errors, get the info to show an error form to the user anfd then get a
screen shot, and a stack trace to send to tech support. Its not that hard to
do.

HTH
Bob

"Michel Vanderbeke" <mi************ ***@skynet.bewr ote in message
news:46******** *************** @news.skynet.be ...
Hello,

When you get an error in a VB.NET program, is it possible to know what is
the origin of the error. I assume it can be VB.NET, the framework, a
database engine, the database itself (Access, SQL Server, ...).

How can you know which source has thrown the exception?
Some error messages are in English, some in my own language.

Many thanks and greetings,

Michel


Aug 10 '07 #3

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

Similar topics

1
1785
by: DS | last post by:
Hi all, Will appreciate if someone can help me with this problem. I am using VS 2003 on Win2000, sp 4. 2GB RAM. Session data is stored on DB on another machine in network. Can connect to the DB (no problem with that). I try to save DB connection string in web.config file, as described in MSDN 'Declaring and Accessing Section Groups'...
6
2875
by: Plat | last post by:
I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology. Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax error. For example, broken.aspx might only contain the following line of code: <% Dim x as %> When I visit this page from my Web browser, I see all...
2
15693
by: Sakke | last post by:
Hello! We have written a GCryptoSvr.dll COM server in C++. Inside that resides WebClient COM component. WebClient CLSID is {8DC27D48-F94C-434B-A509-C3E1A3E75B9E}. When we are using that WebClient COM component from C++ code it works just fine. However when we try to use that same WebClient in the same machine with following C# code: ...
1
9437
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when I try to create my SQL connection in the code-behind, I get the following error. I tried to register the DLL using regsvr32 but that errored out...
6
5839
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList ID="FldType_add" Runat="server" DataSource='< %#GetFieldType()%>' DataValueField="Type" DataTextField="Type" /> Oce the page is loaded all the...
5
1966
by: Sanjay Pais | last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time using the with - over clauses In query analyser, the data is retrieved in under a second. When retrieving using the data adaptor.fill or datareader to retrieve the data it takes over 24 seconds. public System.Data.SqlClient.SqlDataReader List1(int PageIndex, int...
0
3372
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to...
4
18800
by: smartin | last post by:
Hi, I'm having problem retrieving data from an SQL stored procedure. I tried debugging but it wont give a the reason for the error. it just throws an exception after executing cmd.ExecuteNonQuery without any details. Can anyone please help me.. Im stuck on it since 2 days Thanks Stored Procedure
3
2165
by: Bruno Vignola | last post by:
Good Morning all, I need to interoperate with the Calendar of MS Outlook 2003 (inserting, retrieving, listing events, etc. etc.) from an ASP.NET application; I first developed a simple windows application in C# and it worked fine, I added the OL reference and created the COM object with the following code:
0
7629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7549
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8061
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7593
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5455
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.