473,836 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the current procedure name?

Hello,

is there any way to get the name of the current running procedure?

For example:

Public Sub Test( )
'do something
'...

'log activity (for example)
objLog.Write(Te xt := "bla bla bla", _
ProcName := dontKnowWhatIsT his.GetProcName () )
End Sub
Any possibility?

Cesar
Nov 10 '06 #1
6 2604
I don't think it anything will return "Public Sub Test" in your
example, but here's a thread that discusses a few methods:

http://groups.google.com/group/micro...3a0015ecf89e47

Thanks,

Seth Rowe
Ronchese wrote:
Hello,

is there any way to get the name of the current running procedure?

For example:

Public Sub Test( )
'do something
'...

'log activity (for example)
objLog.Write(Te xt := "bla bla bla", _
ProcName := dontKnowWhatIsT his.GetProcName () )
End Sub
Any possibility?

Cesar
------=_NextPart_000_ 0012_01C704EB.3 EC322F0
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Google-AttachSize: 1758

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>Hello,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>is there any way to get the name of the current
running procedure?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>For example:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2>Public Sub Test( )</FONT></DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp; 'do
something</FONT></DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp;
'...</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp; 'log
activity (for example)</FONT></DIV>
<DIV><FONT face="Courier New" size=2>&nbsp;&n bsp;&nbsp; objLog.Write(Te xt :=
"bla bla bla", _</FONT></DIV>
<DIV><FONT face="Courier New" size=2>&nbsp;&n bsp;&nbsp; &nbsp;&nbsp;&nb sp;
&nbsp;&nbsp;&nb sp; &nbsp;&nbsp;&nb sp;&nbsp; ProcName :=
dontKnowWhatIsT his.GetProcName () )</FONT></DIV>
<DIV><FONT face="Courier New" size=2>End Sub</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Any possibility?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Cesar</FONT></DIV></BODY></HTML>

------=_NextPart_000_ 0012_01C704EB.3 EC322F0--
Nov 10 '06 #2
Here is one approach: Get the first frame of the stack trace.

Dim theStackTrace As New StackTrace(True )
Dim theMethod As String =
theStackTrace.G etFrame(0).GetM ethod().ToStrin g
MessageBox.Show (theMethod)

Place the code inside a method to see it get and display the method's
signature.

--
Mike McIntyre
http://www.getdotnetcode.com
"Ronchese" wrote:
Hello,

is there any way to get the name of the current running procedure?

For example:

Public Sub Test( )
'do something
'...

'log activity (for example)
objLog.Write(Te xt := "bla bla bla", _
ProcName := dontKnowWhatIsT his.GetProcName () )
End Sub
Any possibility?

Cesar
Nov 10 '06 #3
That works fine for me. Thanks!

"MikeMc" <Mi****@discuss ions.microsoft. comescreveu na mensagem
news:D1******** *************** ***********@mic rosoft.com...
Here is one approach: Get the first frame of the stack trace.

Dim theStackTrace As New StackTrace(True )
Dim theMethod As String =
theStackTrace.G etFrame(0).GetM ethod().ToStrin g
MessageBox.Show (theMethod)

Place the code inside a method to see it get and display the method's
signature.

--
Mike McIntyre
http://www.getdotnetcode.com
"Ronchese" wrote:
Hello,

is there any way to get the name of the current running procedure?

For example:

Public Sub Test( )
'do something
'...

'log activity (for example)
objLog.Write(Te xt := "bla bla bla", _
ProcName := dontKnowWhatIsT his.GetProcName () )
End Sub
Any possibility?

Cesar

Nov 10 '06 #4
No problem, I dont need the VB sintax togheter, I just needed the procedure
name.
I gave a look in the thread you wrote, also works good like the code MikeMc
wrote.

Thanks.

"rowe_newsgroup s" <ro********@yah oo.comescreveu na mensagem
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
I don't think it anything will return "Public Sub Test" in your
example, but here's a thread that discusses a few methods:

http://groups.google.com/group/micro...es.vb/browse_t
hread/thread/8d8ec2d0f77e7f8 8/c23a0015ecf89e4 7?lnk=gst&q=cur rent+method+nam e
&rnum=2#c23a001 5ecf89e47
>
Thanks,

Seth Rowe
Ronchese wrote:
Hello,

is there any way to get the name of the current running procedure?

For example:

Public Sub Test( )
'do something
'...

'log activity (for example)
objLog.Write(Te xt := "bla bla bla", _
ProcName := dontKnowWhatIsT his.GetProcName () )
End Sub
Any possibility?

Cesar
------=_NextPart_000_ 0012_01C704EB.3 EC322F0
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Google-AttachSize: 1758

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>Hello,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>is there any way to get the name of the
current
running procedure?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>For example:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2>Public Sub Test( )</FONT></DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp;
'do
something</FONT></DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp;
'...</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp;
'log
activity (for example)</FONT></DIV>
<DIV><FONT face="Courier New" size=2>&nbsp;&n bsp;&nbsp;
objLog.Write(Te xt :=
"bla bla bla", _</FONT></DIV>
<DIV><FONT face="Courier New" size=2>&nbsp;&n bsp;&nbsp;
&nbsp;&nbsp;&nb sp;
&nbsp;&nbsp;&nb sp; &nbsp;&nbsp;&nb sp;&nbsp; ProcName :=
dontKnowWhatIsT his.GetProcName () )</FONT></DIV>
<DIV><FONT face="Courier New" size=2>End Sub</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Any possibility?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Cesar</FONT></DIV></BODY></HTML>

------=_NextPart_000_ 0012_01C704EB.3 EC322F0--

Nov 10 '06 #5

Ronchese wrote:
Hello,

is there any way to get the name of the current running procedure?

For example:

Public Sub Test( )
'do something
'...

'log activity (for example)
objLog.Write(Te xt := "bla bla bla", _
ProcName := dontKnowWhatIsT his.GetProcName () )
End Sub
Any possibility?

Cesar
------=_NextPart_000_ 0012_01C704EB.3 EC322F0
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Google-AttachSize: 1758

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial size=2>Hello,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>is there any way to get the name of the current
running procedure?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>For example:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2>Public Sub Test( )</FONT></DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp; 'do
something</FONT></DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp;
'...</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" color=#008000 size=2>&nbsp;&n bsp;&nbsp; 'log
activity (for example)</FONT></DIV>
<DIV><FONT face="Courier New" size=2>&nbsp;&n bsp;&nbsp; objLog.Write(Te xt :=
"bla bla bla", _</FONT></DIV>
<DIV><FONT face="Courier New" size=2>&nbsp;&n bsp;&nbsp; &nbsp;&nbsp;&nb sp;
&nbsp;&nbsp;&nb sp; &nbsp;&nbsp;&nb sp;&nbsp; ProcName :=
dontKnowWhatIsT his.GetProcName () )</FONT></DIV>
<DIV><FONT face="Courier New" size=2>End Sub</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Any possibility?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Cesar</FONT></DIV></BODY></HTML>

------=_NextPart_000_ 0012_01C704EB.3 EC322F0--
You may want to look at System.Reflecti on. IIRC, moduleinfo.

B.

Nov 14 '06 #6
Ronchese wrote:
is there any way to get the name of the current running procedure?
System.Reflecti on.MethodBase.G etCurrentMethod ().Name

HTH,
Phill W.
Nov 15 '06 #7

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

Similar topics

4
10126
by: Rick | last post by:
I want to get a resultset of every table in the database, with the current record count of each. What is the easiest way to do this? I can get the list of tables with: Select s.name from sysobjects s where xtype = 'U' each s.name is a table name, but I'm not sure how to join a record count column to the resultset.
15
3831
by: Philip Mette | last post by:
I am begginner at best so I hope someone that is better can help. I have a stored procedure that updates a view that I wrote using 2 cursors.(Kind of a Inner Loop) I wrote it this way Because I couldn't do it using reqular transact SQL. The problem is that this procedure is taking longer and longer to run. Up to 5 hours now! It is anaylizing about 30,000 records. I think partly because we add new records every month. The procedure...
2
4482
by: deebeetwo | last post by:
On AS/400, is there a way to determine the current library from SQL? (i.e., CURLIB)
1
2394
by: Tony Wilkinson | last post by:
Hi, Does anyone know if it is possible to get the current procedure name from any function or code please. I have had many occassions to need this but have not been able to find a way of doing it. One example of the use I want to put it to is to create a generic error message function that can be called by passing the calling
5
2998
by: Lyn | last post by:
Is there any way of determining in VBA the name and arguments of the currently executed procedure? To assist in debugging, I would like to be able to trace the procedures as they are executed. Then, when it crashes with Access's usual unhelpful error messages, at least I will be able to determine in which procedure it happened. What I had in mind was something like this, inserted as the first statement in every procedure during...
1
3568
by: windandwaves | last post by:
Hi Folks In Google, I read: Jonathan Roenberg Mar 5 2001, 8:35 am Is there a way in VBA to find the name of the current procedure at run time? This would be very helpful for some error checking I'm doing in my
0
1447
by: Alan Carpenter | last post by:
I'm curious about getting to the text of procedures in a database other than the current database without a new instance of Access. Note I don't want to execute or call anything, I just want to get to the text of each module. No Networks involved, just multiple drives on one local machine. <ramble> Win98, Access 8 I don't have the self discipline to keep track of all the incidental bits
13
9214
by: Neil | last post by:
Can I get the name of a procedure from within the procedure? In my error handler, I write the error to an error table. I'd like to write the name of the procedure that's writing the error. But, rather than customizing each error handler with the procedure name, it would be nice to be able to call a system variable or function that gives me the procedure name and module name. Is that possible?
1
4934
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category order, Input field and a submit button. The Category name is being fetched from the oracle db along with the corresponding Category order. In the corresponding input field (text box) the user enters a new category order which gets stored in...
0
9820
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10551
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10594
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5828
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4458
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
2
4020
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.