By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,746 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,746 IT Pros & Developers. It's quick & easy.

How to Parameterise a Logging method

P: n/a
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
Share this Question
Share on Google+
5 Replies

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
Delegates?
Nov 21 '05 #5

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.