Find all SqlCommands added to form

  • Thread starter Thread starter Nawoct
  • Start date Start date
N

Nawoct

Hi,

I am writing some debugging code for my company's web based C# system.
I am trapping errors and send emails to the dev team. What I would like
to do is to find each SqlCommand that is 'on' the particular page and
cycle through its params and get the values for each.

So if I have a handle on the page (I can cycle through the controls)
how do I get to the SqlCommands?

Tim
 
Hi,

You cannot , SqlCommands are not part of the Controls collection.

IMO your algorithm is not correct, you can create a SqlCommand inside a
method and get an exception from it. This instance is not a member of the
page.
Can you modify the code?
 
A better solution here would be to run a trace on the SQL Server that
the page is making calls to, and figuring out the values of the parameters
from that.
 
Thanks Ignacio,

The SqlCommands are already inside methods in each page. We have some
code which is core to every page. It has a handle to every page as it
loads and I wanted to try and make the change once there, as opposed to
adding code to every page that needs it.

Tim
 
Hi,

As I said if the SqlCommand is declared inside the method you cannot access
it , at least I do not know a method for doing it, you would have to modify
the code.
 
Back
Top