473,322 Members | 1,614 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,322 software developers and data experts.

class to display calling routine in error

I have a public class that I use to read columns out of a SQL database.

In the try, catch, loop I want to display the error, and in the error I
want to display the calling routine (and helpfully the line # from the
calling routine).

Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.

Darin

*** Sent via Developersdex http://www.developersdex.com ***
Jun 19 '07 #1
4 1424
On Jun 19, 11:23 am, Darin <darin_nospam@nospameverwrote:
I have a public class that I use to read columns out of a SQL database.

In the try, catch, loop I want to display the error, and in the error I
want to display the calling routine (and helpfully the line # from the
calling routine).

Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.

Darin

*** Sent via Developersdexhttp://www.developersdex.com***
I would suggest hardcoding a msgbox for intermediate debugging. In
the catch part, use the Msgbox(label where and why and add your
Exception value (ex.ToString)).

Jun 19 '07 #2
On Jun 19, 11:28 am, Lucas <lucaslshaf...@gmail.comwrote:
On Jun 19, 11:23 am, Darin <darin_nospam@nospameverwrote:
I have a public class that I use to read columns out of a SQL database.
In the try, catch, loop I want to display the error, and in the error I
want to display the calling routine (and helpfully the line # from the
calling routine).
Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.
Darin
*** Sent via Developersdexhttp://www.developersdex.com***

I would suggest hardcoding a msgbox for intermediate debugging. In
the catch part, use the Msgbox(label where and why and add your
Exception value (ex.ToString)).
try this.

Try
do.Something
Catch ex As SqlClient.SqlException
MsgBox("Problem Here" & vbCrLf & ex.ToString,
MsgBoxStyle.Information, "Inside the Loop")
End Try

You can play around with the exception members. This exception would
retrieve the sys info relative to the SQL client.

Jun 19 '07 #3
On Jun 19, 11:33 am, Lucas <lucaslshaf...@gmail.comwrote:
On Jun 19, 11:28 am, Lucas <lucaslshaf...@gmail.comwrote:


On Jun 19, 11:23 am, Darin <darin_nospam@nospameverwrote:
I have a public class that I use to read columns out of a SQL database.
In the try, catch, loop I want to display the error, and in the error I
want to display the calling routine (and helpfully the line # from the
calling routine).
Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.
Darin
*** Sent via Developersdexhttp://www.developersdex.com***
I would suggest hardcoding a msgbox for intermediate debugging. In
the catch part, use the Msgbox(label where and why and add your
Exception value (ex.ToString)).

try this.

Try
do.Something
Catch ex As SqlClient.SqlException
MsgBox("Problem Here" & vbCrLf & ex.ToString,
MsgBoxStyle.Information, "Inside the Loop")
End Try

You can play around with the exception members. This exception would
retrieve the sys info relative to the SQL client.- Hide quoted text -

- Show quoted text -
Later, once intermediate debugging is done. You can use the catch to
write to a log file or however you will record your error handling.

Jun 19 '07 #4
Darin wrote:
In the try, catch, loop I want to display the error
.... that would be ex.Message ...
and in the error I want to display the calling routine
(and helpfully the line # from the calling routine).
That's in the StackTrace, not the message.
Is that possible? The stacktrace gives me the system information (at
system.data.sqlclient.sqlconnection.onerror, etc). I am looking for my
routine that called it.
The StackTrace should include /every/ method in the current call chain
from the method at which you first entered the assembly, usually Main()
for an executable, all the way down to the method that threw the Exception.

ex.ToString() gets you the whole shooting match in one, giant, loggable
chunk.

If you really /need/ line numbers (although, personally, I think them
unnecessary) then you have to ship the .pdb file alongside your
executable; the run-time will interrogate this when the Exception is
constructed.

HTH,
Phill W.
Jun 20 '07 #5

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

Similar topics

4
by: Michael Farber | last post by:
Not sure if this is the right group for this but anyways... I've got an ASP web application that uses a Visual Basic component to do some work. I instantiate the component in asp and then...
1
by: Private Pyle | last post by:
DB2 version 8, fixpack 5. Aix 5.1.0.0 Using C for AIX compiler. I'm having a problem where I can create stored procedures but I'm getting -444 when I call them. It's a new environment for...
17
by: ahaupt | last post by:
Hi all, I'm currently writing a load of class libraries, but not the main application iteslf. I want to provide some method for reporting errors back to the main application. At the moment...
7
by: hansiman | last post by:
I'm unsure how best to handle errors in the scenario below! Say I have a class Employee that handles everything about employees. The class has two properties "id" and "name", and on procedure...
9
by: Brian Henry | last post by:
If i inherite a queue class into my class, and do an override of the enqueue member, how would i then go about actually doing an enqueue of an item? I am a little confused on this one... does over...
2
by: tshad | last post by:
I have a Base Page Class that I built am just starting to use. In my aspx page I have: <%@ Page Language="VB" trace="true" ContentType="text/html" ResponseEncoding="iso-8859-1"...
3
by: StephQ | last post by:
In utility.hpp I have: namespace utility { template <class T, double (T::*F)(double) const> class Display { private: static double resolution;
4
by: Bails | last post by:
Hi Im an absolute beginner in programming and am using VB.Net Express. To start my larning I decided to do a "Real World" app instead of "hello world" and am creating a Poker Countdown clock. ...
0
by: aravindalapat | last post by:
Hi All, I am facing an error when I try to invoke a remote nested stored proc. Please find the details below. 1) SP TEST1 is defined in DB2 instance DB2A. It is calling a stored procedure ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.