473,545 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.sql client.sqlconne ction.onerror, etc). I am looking for my
routine that called it.

Darin

*** Sent via Developersdex http://www.developersdex.com ***
Jun 19 '07 #1
4 1433
On Jun 19, 11:23 am, Darin <darin_nospam@n ospameverwrote:
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.sql client.sqlconne ction.onerror, etc). I am looking for my
routine that called it.

Darin

*** Sent via Developersdexht tp://www.developersd ex.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@n ospameverwrote:
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.sql client.sqlconne ction.onerror, etc). I am looking for my
routine that called it.
Darin
*** Sent via Developersdexht tp://www.developersd ex.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.SqlEx ception
MsgBox("Problem Here" & vbCrLf & ex.ToString,
MsgBoxStyle.Inf ormation, "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@n ospameverwrote:
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.sql client.sqlconne ction.onerror, etc). I am looking for my
routine that called it.
Darin
*** Sent via Developersdexht tp://www.developersd ex.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.SqlEx ception
MsgBox("Problem Here" & vbCrLf & ex.ToString,
MsgBoxStyle.Inf ormation, "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.sql client.sqlconne ction.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
4960
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 attempt to call the subroutine. The subroutine is actually invoked maybe 2 out of 10 times run. What could possibly be the reason for this?? Why the...
1
7322
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 running SP's so I wrote a very simple procedure just to make sure everything is working. Below is the db2set output for the...
17
7591
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 I have a bool errBl and a string errMsg in my classes. When errBl is ture, one could see what the error was in errMsg.
7
1256
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 "create" that simply inserts a new employee into the database. Any error I'd like to show to the user. But how do I make an error that occurs in the...
9
2485
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 ride just add aditional code ontop of the current class or completely over ride it in vb? I am use to C++ this is the first inherited thing I've...
2
1674
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" Inherits="MyFunctions.Page" %> I also have a dll that I call in my Page_load as: Sub Page_Load(s as Object, e as EventArgs) if not IsPostBack then
3
5781
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
2805
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. I pretty much have most things under control and have set it up as follows: Form 1 Contains a DataGridView where users enter in information...
0
1405
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 REMOTE1 which is defined in another instance DB2B. 2) Before actually calling REMOTE1, the calling stored procedure is connecting to DB2B...
0
7401
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
7808
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...
0
7757
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...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4945
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
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
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.