How to Parameterise a Logging method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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...
 
i forgot this part of the code

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top