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

How to Parameterise a Logging method

Briefly, I have a loop which runs a number of sProcs from a CheckedListBox.
Within this loop I do the following to achieve this...

GetExecRoutines()
RunExecRoutines()

I need to log to a textbox for each sProc that is run. So I tried the
following which does work but how the hell do I avoid the hard-coding and set
up relevant parameters. ProcToExec is a string taken from a SQL Table which
holds a value such as 'dbo.usp_MISRE_Pivot' which I use in the
RunExecRoutines() to execute the user selections.

I am banging my head off the wall and just can't see a way right now.

Please stop my head-banging.

If ProcToExec = "dbo.usp_MISRE_Pivot" Then
PivotLog()
ElseIf ProcToExec = "dbo.Routine4" Then
Routine4Log
End If
Nov 21 '05 #1
5 961
There are a few ways to do this, but one straightforward way is to put print
statements in your code, and then trap the InfoMessage event of your
connection. (I mean this as a general way to get information back from your
stored procedures). Each time a Print is encountered in your stored proc,
then it will be visible in the InfoMessage event
http://www.knowdotnet.com/articles/connections.html

The reason I recommend this is that you can exert a high degree of control
over your statements and it's VERY easy to implement.

The other way would be to store the values in a database table (along with
their respective parameters), or use a web service or dataset (serialized
locally for example) and get the values from there.

I'd
"marcmc" <ma****@discussions.microsoft.com> wrote in message
news:F4**********************************@microsof t.com...
Briefly, I have a loop which runs a number of sProcs from a
CheckedListBox.
Within this loop I do the following to achieve this...

GetExecRoutines()
RunExecRoutines()

I need to log to a textbox for each sProc that is run. So I tried the
following which does work but how the hell do I avoid the hard-coding and
set
up relevant parameters. ProcToExec is a string taken from a SQL Table
which
holds a value such as 'dbo.usp_MISRE_Pivot' which I use in the
RunExecRoutines() to execute the user selections.

I am banging my head off the wall and just can't see a way right now.

Please stop my head-banging.

If ProcToExec = "dbo.usp_MISRE_Pivot" Then
PivotLog()
ElseIf ProcToExec = "dbo.Routine4" Then
Routine4Log
End If

Nov 21 '05 #2
I read the connections code. It doesn't seem to apply here.
I have also tried the table parameter code as follows but I can't seem to
get it to work...

GetExecRoutines()
RunExecRoutines()
Log(ProcToLog)

ProcToLog in the first loop case is 'PivotLog()' which is a function I want
to execute after the 1st procedure similarly;
ProcToLog is 'Routine4Log()' which is a function I want to execute after the
2st procedure completes

Am I thinking about this the right way. I have also tried CASE statements
but just can't seem to get the right syntax...

Nov 21 '05 #3
i forgot this part of the code

Private Function Log(ByVal ProcToLog)
'How can I process ProcToLog
End Function

"marcmc" wrote:
I read the connections code. It doesn't seem to apply here.
I have also tried the table parameter code as follows but I can't seem to
get it to work...

GetExecRoutines()
RunExecRoutines()
Log(ProcToLog)

ProcToLog in the first loop case is 'PivotLog()' which is a function I want
to execute after the 1st procedure similarly;
ProcToLog is 'Routine4Log()' which is a function I want to execute after the
2st procedure completes

Am I thinking about this the right way. I have also tried CASE statements
but just can't seem to get the right syntax...

Nov 21 '05 #4
Delegates?
Nov 21 '05 #5
come on guys, don't leave me now!
"marcmc" wrote:
Briefly, I have a loop which runs a number of sProcs from a CheckedListBox.
Within this loop I do the following to achieve this...

GetExecRoutines()
RunExecRoutines()

I need to log to a textbox for each sProc that is run. So I tried the
following which does work but how the hell do I avoid the hard-coding and set
up relevant parameters. ProcToExec is a string taken from a SQL Table which
holds a value such as 'dbo.usp_MISRE_Pivot' which I use in the
RunExecRoutines() to execute the user selections.

I am banging my head off the wall and just can't see a way right now.

Please stop my head-banging.

If ProcToExec = "dbo.usp_MISRE_Pivot" Then
PivotLog()
ElseIf ProcToExec = "dbo.Routine4" Then
Routine4Log
End If

Nov 21 '05 #6

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

Similar topics

3
by: Frantisek Fuka | last post by:
I am using the standard "logging" module included with Python and it seems it doesn't correctly identify the filename (and thus module name) from where the logging method was called. In fact, no...
8
by: Steve Erickson | last post by:
I have a logger class that uses the Python logging module. When I call it within a program using the unittest module, I get one line in the log file for the first test, two identical ones for the...
3
by: Birgit Rahm | last post by:
Hello newsgroup, I work with omniORB for python and I what to log the calls, does anyone in this group know how I can do this? I use the command to initialize the ORB ORB =...
16
by: Einar Høst | last post by:
Hi, I'm getting into the Trace-functionality in .NET, using it to provide some much-needed logging across dlls in the project we're working on. However, being a newbie, I'm wondering if some...
0
by: rshekhtm | last post by:
Hi everyone, I would like to get your opinion on a technique I came up with when faced with the problem of redundant code in every web method (authentication, logging, exception handling)....
12
by: Eric S. Johansson | last post by:
I need to to be able to conditionally log based on the method the log statement is in and one other factor like a log level. in order to do so, I need to be able to automatically find out the name...
19
by: =?Utf-8?B?Sko=?= | last post by:
I have a logging component that I will access in other assemblies. So it was brought up to me that I should pass an instance around to these components instead of just making the logging class...
5
by: IdleBrain | last post by:
I am trying to log the Application name, Method name, line number and column number whenever an exception is generated in an C# 2005 application using the following code. Problem is that the...
4
by: Alexandru Mosoi | last post by:
why doesn't logging throw any exception when it should? how do I configure logging to throw exceptions? .... logging.fatal('asdf %d', '123') .... except: .... print 'this line is never...
1
by: arunairs | last post by:
Hi, Using the EnterpriseLibrary 4.0, is it possible to Log the method name in the log file. I have it cofigured thus: <loggingConfiguration name="Logging Application Block"...
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...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: 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.